<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>Action Name Lists</title>
<link href="../docs-assets/Breadcrumbs.css" rel="stylesheet" rev="stylesheet" type="text/css">
		<meta name="viewport" content="width=device-width initial-scale=1">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="Content-Language" content="en-gb">

<link href="../docs-assets/Contents.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Progress.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Navigation.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Fonts.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Base.css" rel="stylesheet" rev="stylesheet" type="text/css">
<script>
function togglePopup(material_id) {
  var popup = document.getElementById(material_id);
  popup.classList.toggle("show");
}
</script>

<link href="../docs-assets/Popups.css" rel="stylesheet" rev="stylesheet" type="text/css">
<script>
MathJax = {
	tex: {
		inlineMath: '$', '$'], ['\\(', '\\)'
	},
	svg: {
		fontCache: 'global'
	}
};
</script>
<script type="text/javascript" id="MathJax-script" async
	src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js">
</script>

<link href="../docs-assets/Colours.css" rel="stylesheet" rev="stylesheet" type="text/css">
		
	</head>
	<body class="commentary-font">
		<nav role="navigation">
		<h1><a href="../index.html"><img src="../docs-assets/Inform.png" height=72> </a></h1>
<ul><li><a href="../index.html">home</a></li>
</ul><h2>Compiler</h2><ul>
<li><a href="../structure.html">structure</a></li>
<li><a href="../inbuildn.html">inbuild</a></li>
<li><a href="../inform7n.html">inform7</a></li>
<li><a href="../intern.html">inter</a></li>
<li><a href="../services.html">services</a></li>
<li><a href="../secrets.html">secrets</a></li>
</ul><h2>Other Tools</h2><ul>
<li><a href="../inblorbn.html">inblorb</a></li>
<li><a href="../inform6.html">inform6</a></li>
<li><a href="../inpolicyn.html">inpolicy</a></li>
</ul><h2>Resources</h2><ul>
<li><a href="../extensions.html">extensions</a></li>
<li><a href="../kits.html">kits</a></li>
</ul><h2>Repository</h2><ul>
<li><a href="https://github.com/ganelson/inform"><img src="../docs-assets/github.png" height=0> github</a></li>
</ul><h2>Related Projects</h2><ul>
<li><a href="https://github.com/ganelson/inweb"><img src="../docs-assets/github.png" height=0> inweb</a></li>
<li><a href="https://github.com/ganelson/intest"><img src="../docs-assets/github.png" height=0> intest</a></li>
</ul>
		</nav>
		<main role="main">
		<!-- Weave of 'Action Name Lists' generated by inweb -->
<div class="breadcrumbs">
    <ul class="crumbs"><li><a href="../index.html">Home</a></li><li><a href="../inform7n.html">Inform7</a></li><li><a href="index.html">if</a></li><li><a href="index.html#4">Chapter 4: Actions</a></li><li><b>Action Name Lists</b></li></ul></div>
<p class="purpose">Action name lists are used in parsing action patterns, and identify which action names seem to be possible within them.</p>

<ul class="toc"><li><a href="4-anl.html#SP1">&#167;1. Data structure</a></li><li><a href="4-anl.html#SP23">&#167;23. Single and best actions</a></li><li><a href="4-anl.html#SP26">&#167;26. Duplication</a></li><li><a href="4-anl.html#SP27">&#167;27. Logging</a></li><li><a href="4-anl.html#SP28">&#167;28. Parsing text to an ANL</a></li></ul><hr class="tocbar">

<p class="commentary firstcommentary"><a id="SP1" class="paragraph-anchor"></a><b>&#167;1. Data structure.</b>An ANL is a head object, an <a href="4-anl.html#SP1" class="internal">action_name_list</a>, which points to a linked
list of <a href="4-anl.html#SP4" class="internal">anl_entry</a> objects.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">action_name_list</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">entries</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">negation_state</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">test_this_in_ap_match</span><span class="plain-syntax">;</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">action_name_list</span><span class="plain-syntax">;</span>

<span class="reserved-syntax">action_name_list</span><span class="plain-syntax"> *</span><span class="function-syntax">ActionNameLists::new_list</span><button class="popup" onclick="togglePopup('usagePopup1')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup1">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::new_list</span></span>:<br/><a href="4-anl.html#SP30_1">&#167;30.1</a>, <a href="4-anl.html#SP30_2">&#167;30.2</a>, <a href="4-anl.html#SP30_3">&#167;30.3</a>, <a href="4-anl.html#SP30_4">&#167;30.4</a>, <a href="4-anl.html#SP30_5">&#167;30.5</a>, <a href="4-anl.html#SP30_6">&#167;30.6</a><br/>Parse Clauses - <a href="4-pc.html#SP4_4">&#167;4.4</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">first</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">state</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">action_name_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">list</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CREATE</span><span class="plain-syntax">(</span><span class="reserved-syntax">action_name_list</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">list</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">entries</span><span class="plain-syntax"> = </span><span class="identifier-syntax">first</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">list</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">negation_state</span><span class="plain-syntax"> = </span><span class="identifier-syntax">state</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">list</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">test_this_in_ap_match</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>The structure action_name_list is private to this section.</li></ul>
<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>&#167;2. </b>The "negation state" of a list is one of three possibilities, not two. The
difference is that "doing something other than examining the box", for example,
is <span class="extract"><span class="extract-syntax">ANL_NEGATED_LISTWISE</span></span>, whereas "doing something other than examining to the
box" is <span class="extract"><span class="extract-syntax">ANL_NEGATED_ITEMWISE</span></span>. Note that the state is set irrevocably when the
list is created.
</p>

<pre class="definitions code-font"><span class="definition-keyword">define</span> <span class="constant-syntax">ANL_POSITIVE</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span>
<span class="definition-keyword">define</span> <span class="constant-syntax">ANL_NEGATED_LISTWISE</span><span class="plain-syntax"> </span><span class="constant-syntax">2</span>
<span class="definition-keyword">define</span> <span class="constant-syntax">ANL_NEGATED_ITEMWISE</span><span class="plain-syntax"> </span><span class="constant-syntax">3</span>
</pre>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">ActionNameLists::listwise_negated</span><button class="popup" onclick="togglePopup('usagePopup2')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup2">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::listwise_negated</span></span>:<br/><a href="4-anl.html#SP27">&#167;27</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_name_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">list</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">list</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">list</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">negation_state</span><span class="plain-syntax"> == </span><span class="constant-syntax">ANL_NEGATED_LISTWISE</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">ActionNameLists::itemwise_negated</span><button class="popup" onclick="togglePopup('usagePopup3')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup3">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::itemwise_negated</span></span>:<br/><a href="4-anl.html#SP27">&#167;27</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_name_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">list</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">list</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">list</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">negation_state</span><span class="plain-syntax"> == </span><span class="constant-syntax">ANL_NEGATED_ITEMWISE</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">ActionNameLists::positive</span><button class="popup" onclick="togglePopup('usagePopup4')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup4">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::positive</span></span>:<br/><a href="4-anl.html#SP13">&#167;13</a>, <a href="4-anl.html#SP14">&#167;14</a>, <a href="4-anl.html#SP23">&#167;23</a>, <a href="4-anl.html#SP25">&#167;25</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_name_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">list</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">list</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) || (</span><span class="identifier-syntax">list</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">negation_state</span><span class="plain-syntax"> == </span><span class="constant-syntax">ANL_POSITIVE</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP3" class="paragraph-anchor"></a><b>&#167;3. </b>It is sometimes possible when matching action patterns to prove that it
is unnecessary to test that the action appears in this list; and then the
list can be marked accordingly:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">ActionNameLists::suppress_action_testing</span><button class="popup" onclick="togglePopup('usagePopup5')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup5">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::suppress_action_testing</span></span>:<br/>Action Patterns - <a href="4-ap2.html#SP7">&#167;7</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_name_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">list</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">list</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">test_this_in_ap_match</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">ActionNameLists::testing</span><span class="plain-syntax">(</span><span class="reserved-syntax">action_name_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">list</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">list</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">test_this_in_ap_match</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>&#167;4. </b>An entry has some book-keeping fields, and is otherwise divided into the
item itself &mdash; either an action name or a named action pattern &mdash; and some
parsing data needed by the complicated algorithms for turning text into an
action list.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">anl_item</span><span class="plain-syntax"> </span><span class="identifier-syntax">item</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">anl_parsing_data</span><span class="plain-syntax"> </span><span class="reserved-syntax">parsing_data</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">marked_for_deletion</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">next_entry</span><span class="plain-syntax">; </span><span class="comment-syntax"> next in this ANL list</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax">;</span>

<span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="function-syntax">ActionNameLists::new_entry_at</span><button class="popup" onclick="togglePopup('usagePopup6')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup6">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::new_entry_at</span></span>:<br/><a href="4-anl.html#SP26">&#167;26</a>, <a href="4-anl.html#SP30_1">&#167;30.1</a>, <a href="4-anl.html#SP30_2">&#167;30.2</a>, <a href="4-anl.html#SP30_3">&#167;30.3</a>, <a href="4-anl.html#SP33">&#167;33</a>, <a href="4-anl.html#SP34_1">&#167;34.1</a>, <a href="4-anl.html#SP34_1_4">&#167;34.1.4</a><br/>Parse Clauses - <a href="4-pc.html#SP4_4">&#167;4.4</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">W</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">entry</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CREATE</span><span class="plain-syntax">(</span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">item</span><span class="plain-syntax"> = </span><a href="4-anl.html#SP12" class="function-link"><span class="function-syntax">ActionNameLists::new_item</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> = -1;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Wordings::nonempty</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">)) </span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Wordings::first_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">parsing_data</span><span class="plain-syntax"> = </span><a href="4-anl.html#SP15" class="function-link"><span class="function-syntax">ActionNameLists::new_parsing_data</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">at</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">marked_for_deletion</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">entry</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>The structure anl_entry is accessed in 4/pc and here.</li></ul>
<p class="commentary firstcommentary"><a id="SP5" class="paragraph-anchor"></a><b>&#167;5. </b>The model here is that the list can be reduced in size by marking entries
for deletion and then, subsequently, having all such entries removed. Note
that the head <a href="4-anl.html#SP1" class="internal">action_name_list</a> object remains valid even if every entry
is removed.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">ActionNameLists::mark_for_deletion</span><button class="popup" onclick="togglePopup('usagePopup7')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup7">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::mark_for_deletion</span></span>:<br/>Parse Clauses - <a href="4-pc.html#SP1_1">&#167;1.1</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">X</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">X</span><span class="plain-syntax">) </span><span class="identifier-syntax">X</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">marked_for_deletion</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"tried to mark null entry for deletion"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">ActionNameLists::marked_for_deletion</span><span class="plain-syntax">(</span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">X</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">X</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">X</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">marked_for_deletion</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP6" class="paragraph-anchor"></a><b>&#167;6. </b>This function actually does two things: deletes unwanted entries, and deletes
entries which fail to change the word position.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">ActionNameLists::remove_entries_marked_for_deletion</span><button class="popup" onclick="togglePopup('usagePopup8')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup8">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::remove_entries_marked_for_deletion</span></span>:<br/>Parse Clauses - <a href="4-pc.html#SP1_1">&#167;1.1</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_name_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">list</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">list</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">pos</span><span class="plain-syntax"> = -2;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">entry</span><span class="plain-syntax"> = </span><span class="identifier-syntax">list</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">entries</span><span class="plain-syntax">, *</span><span class="identifier-syntax">prev</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">; </span><span class="identifier-syntax">entry</span><span class="plain-syntax">; </span><span class="identifier-syntax">entry</span><span class="plain-syntax"> = </span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next_entry</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Log::aspect_switched_on</span><span class="plain-syntax">(</span><span class="constant-syntax">ACTION_PATTERN_PARSING_DA</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">                </span><a href="4-anl.html#SP27" class="function-link"><span class="function-syntax">ActionNameLists::log_entry</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">); </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">" (wp %d)"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">parsing_data</span><span class="plain-syntax">.</span><span class="element-syntax">word_position</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">delete</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">marked_for_deletion</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">delete</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">ACTION_PATTERN_PARSING</span><span class="plain-syntax">, </span><span class="string-syntax">": marked, so delete\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">pos</span><span class="plain-syntax"> == </span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">parsing_data</span><span class="plain-syntax">.</span><span class="element-syntax">word_position</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">delete</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">ACTION_PATTERN_PARSING</span><span class="plain-syntax">, </span><span class="string-syntax">": fails to advance, so delete\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">ACTION_PATTERN_PARSING</span><span class="plain-syntax">, </span><span class="string-syntax">": retain\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">delete</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">prev</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">list</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">entries</span><span class="plain-syntax"> = </span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next_entry</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">prev</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next_entry</span><span class="plain-syntax"> = </span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next_entry</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">prev</span><span class="plain-syntax"> = </span><span class="identifier-syntax">entry</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">pos</span><span class="plain-syntax"> = </span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">parsing_data</span><span class="plain-syntax">.</span><span class="element-syntax">word_position</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP7" class="paragraph-anchor"></a><b>&#167;7. </b>The list must be kept in a strict order, as can be seen:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">ActionNameLists::join_to</span><button class="popup" onclick="togglePopup('usagePopup9')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup9">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::join_to</span></span>:<br/><a href="4-anl.html#SP9_1">&#167;9.1</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">earlier</span><span class="plain-syntax">, </span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">later</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">later</span><span class="plain-syntax"> == </span><span class="identifier-syntax">earlier</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"loop"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="4-anl.html#SP8" class="function-link"><span class="function-syntax">ActionNameLists::precedes</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">later</span><span class="plain-syntax">, </span><span class="identifier-syntax">earlier</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">STDERR</span><span class="plain-syntax">, </span><span class="string-syntax">"Earlier: "</span><span class="plain-syntax">); </span><a href="4-anl.html#SP27" class="function-link"><span class="function-syntax">ActionNameLists::write_entry_briefly</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">STDERR</span><span class="plain-syntax">, </span><span class="identifier-syntax">earlier</span><span class="plain-syntax">); </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">STDERR</span><span class="plain-syntax">, </span><span class="string-syntax">"\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">STDERR</span><span class="plain-syntax">, </span><span class="string-syntax">"Later:   "</span><span class="plain-syntax">); </span><a href="4-anl.html#SP27" class="function-link"><span class="function-syntax">ActionNameLists::write_entry_briefly</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">STDERR</span><span class="plain-syntax">, </span><span class="identifier-syntax">later</span><span class="plain-syntax">); </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">STDERR</span><span class="plain-syntax">, </span><span class="string-syntax">"\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"misordering"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">earlier</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next_entry</span><span class="plain-syntax"> = </span><span class="identifier-syntax">later</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP8" class="paragraph-anchor"></a><b>&#167;8. </b>Which uses the following function:
</p>

<ul class="items"><li>&#9679; Results in later word positions come first, and if that doesn't decide it
</li><li>&#9679; NAPs come before actions, and if that doesn't decide it
</li><li>&#9679; Older NAPs come before younger ones, and if that doesn't decide it
</li><li>&#9679; Less abbreviated results come first, and if that doesn't decide it
</li><li>&#9679; Action names with longer non-it-length come before shorter, and if that doesn't decide it
</li><li>&#9679; Older action names come before younger, and if that doesn't decide it
</li><li>&#9679; Later-discovered results come before earlier ones &mdash; which because of the
way we parse them means that results with more fixed words in clauses come
before those with fewer.
</li></ul>
<p class="commentary">Here, "older" and "younger" mean how long ago the relevant <a href="4-nap.html#SP1" class="internal">named_action_pattern</a>
or <a href="4-act.html#SP1" class="internal">action_name</a> objects were created, and since this happens in source text
order, we are really saying "closer to the top of the source text" when we
say "older".
</p>

<p class="commentary">Note that this function is transitive (\(p(x, y)\) and \(p(y, z)\) implies \(p(x, z)\))
and antisymmetric (\(p(x, y)\) implies that \(p(y, x)\) is false). Strictly speaking
it is not trichotomous, but if neither \(p(x, y)\) nor \(p(y, x)\) then \(x\) and \(y\)
have identical item data; and in that case it doesn't matter which way round they
are in the list.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">ActionNameLists::precedes</span><button class="popup" onclick="togglePopup('usagePopup10')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup10">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::precedes</span></span>:<br/><a href="4-anl.html#SP7">&#167;7</a>, <a href="4-anl.html#SP9_1">&#167;9.1</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">e1</span><span class="plain-syntax">, </span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">e2</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">e1</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">e2</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">c</span><span class="plain-syntax"> = </span><span class="identifier-syntax">e1</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">parsing_data</span><span class="plain-syntax">.</span><span class="element-syntax">word_position</span><span class="plain-syntax"> -</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">e2</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">parsing_data</span><span class="plain-syntax">.</span><span class="element-syntax">word_position</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">; </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">c</span><span class="plain-syntax"> = ((</span><span class="identifier-syntax">e1</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">item</span><span class="plain-syntax">.</span><span class="element-syntax">nap_listed</span><span class="plain-syntax">)?(</span><span class="identifier-syntax">e1</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">item</span><span class="plain-syntax">.</span><span class="element-syntax">nap_listed</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">allocation_id</span><span class="plain-syntax">):10000000) -</span>
<span class="plain-syntax">        ((</span><span class="identifier-syntax">e2</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">item</span><span class="plain-syntax">.</span><span class="element-syntax">nap_listed</span><span class="plain-syntax">)?(</span><span class="identifier-syntax">e2</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">item</span><span class="plain-syntax">.</span><span class="element-syntax">nap_listed</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">allocation_id</span><span class="plain-syntax">):10000000);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">; </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">c</span><span class="plain-syntax"> = </span><span class="identifier-syntax">e1</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">parsing_data</span><span class="plain-syntax">.</span><span class="element-syntax">abbreviation_level</span><span class="plain-syntax"> -</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">e2</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">parsing_data</span><span class="plain-syntax">.</span><span class="element-syntax">abbreviation_level</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">; </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">c</span><span class="plain-syntax"> = ((</span><span class="identifier-syntax">e1</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">item</span><span class="plain-syntax">.</span><span class="element-syntax">action_listed</span><span class="plain-syntax">)?(</span><a href="4-ann.html#SP7" class="function-link"><span class="function-syntax">ActionNameNames::non_it_length</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">e1</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">item</span><span class="plain-syntax">.</span><span class="element-syntax">action_listed</span><span class="plain-syntax">)):10000000) -</span>
<span class="plain-syntax">        ((</span><span class="identifier-syntax">e2</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">item</span><span class="plain-syntax">.</span><span class="element-syntax">action_listed</span><span class="plain-syntax">)?(</span><a href="4-ann.html#SP7" class="function-link"><span class="function-syntax">ActionNameNames::non_it_length</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">e2</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">item</span><span class="plain-syntax">.</span><span class="element-syntax">action_listed</span><span class="plain-syntax">)):10000000);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">; </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">c</span><span class="plain-syntax"> = ((</span><span class="identifier-syntax">e1</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">item</span><span class="plain-syntax">.</span><span class="element-syntax">action_listed</span><span class="plain-syntax">)?(</span><span class="identifier-syntax">e1</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">item</span><span class="plain-syntax">.</span><span class="element-syntax">action_listed</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">allocation_id</span><span class="plain-syntax">):10000000) -</span>
<span class="plain-syntax">        ((</span><span class="identifier-syntax">e2</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">item</span><span class="plain-syntax">.</span><span class="element-syntax">action_listed</span><span class="plain-syntax">)?(</span><span class="identifier-syntax">e2</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">item</span><span class="plain-syntax">.</span><span class="element-syntax">action_listed</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">allocation_id</span><span class="plain-syntax">):10000000);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">; </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP9" class="paragraph-anchor"></a><b>&#167;9. </b>These lists are never long, so we don't need to worry about running time here.
</p>

<p class="commentary">On entry <span class="extract"><span class="extract-syntax">main_list</span></span> begins a linked list in which each entry <a href="4-anl.html#SP8" class="internal">ActionNameLists::precedes</a>
the next; while <span class="extract"><span class="extract-syntax">new_list</span></span> can be in any sequence, but must be disjoint from the
<span class="extract"><span class="extract-syntax">main_list</span></span>, i.e., have no entries in common.
</p>

<p class="commentary">On exit the return value heads a linked list in which each entry precedes the
next, and which includes exactly the members of the two lists passed to it.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="function-syntax">ActionNameLists::join_entries</span><button class="popup" onclick="togglePopup('usagePopup11')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup11">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::join_entries</span></span>:<br/><a href="4-anl.html#SP31">&#167;31</a>, <a href="4-anl.html#SP34_1_4">&#167;34.1.4</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">new_list</span><span class="plain-syntax">, </span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">main_list</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">new_list</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">main_list</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">main_list</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">new_list</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">X</span><span class="plain-syntax"> = </span><span class="identifier-syntax">new_list</span><span class="plain-syntax">; </span><span class="identifier-syntax">X</span><span class="plain-syntax">; </span><span class="identifier-syntax">X</span><span class="plain-syntax"> = </span><span class="identifier-syntax">X</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next_entry</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">Y</span><span class="plain-syntax"> = </span><span class="identifier-syntax">main_list</span><span class="plain-syntax">; </span><span class="identifier-syntax">Y</span><span class="plain-syntax">; </span><span class="identifier-syntax">Y</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Y</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next_entry</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">X</span><span class="plain-syntax"> == </span><span class="identifier-syntax">Y</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"ANLs not disjoint"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">new_entry</span><span class="plain-syntax"> = </span><span class="identifier-syntax">new_list</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">while</span><span class="plain-syntax"> (</span><span class="identifier-syntax">new_entry</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">next_entry</span><span class="plain-syntax"> = </span><span class="identifier-syntax">new_entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next_entry</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">new_entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next_entry</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="4-anl.html#SP9_1" class="named-paragraph-link"><span class="named-paragraph">Insertion-sort the new entry into the main list</span><span class="named-paragraph-number">9.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">new_entry</span><span class="plain-syntax"> = </span><span class="identifier-syntax">next_entry</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">main_list</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP9_1" class="paragraph-anchor"></a><b>&#167;9.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Insertion-sort the new entry into the main list</span><span class="named-paragraph-number">9.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="4-anl.html#SP8" class="function-link"><span class="function-syntax">ActionNameLists::precedes</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">new_entry</span><span class="plain-syntax">, </span><span class="identifier-syntax">main_list</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><a href="4-anl.html#SP7" class="function-link"><span class="function-syntax">ActionNameLists::join_to</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">new_entry</span><span class="plain-syntax">, </span><span class="identifier-syntax">main_list</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">main_list</span><span class="plain-syntax"> = </span><span class="identifier-syntax">new_entry</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">prev</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, *</span><span class="identifier-syntax">pos</span><span class="plain-syntax"> = </span><span class="identifier-syntax">main_list</span><span class="plain-syntax">; </span><span class="identifier-syntax">pos</span><span class="plain-syntax">; </span><span class="identifier-syntax">prev</span><span class="plain-syntax"> = </span><span class="identifier-syntax">pos</span><span class="plain-syntax">, </span><span class="identifier-syntax">pos</span><span class="plain-syntax"> = </span><span class="identifier-syntax">pos</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next_entry</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="4-anl.html#SP8" class="function-link"><span class="function-syntax">ActionNameLists::precedes</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">new_entry</span><span class="plain-syntax">, </span><span class="identifier-syntax">pos</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">prev</span><span class="plain-syntax">) </span><a href="4-anl.html#SP7" class="function-link"><span class="function-syntax">ActionNameLists::join_to</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">prev</span><span class="plain-syntax">, </span><span class="identifier-syntax">new_entry</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><a href="4-anl.html#SP7" class="function-link"><span class="function-syntax">ActionNameLists::join_to</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">new_entry</span><span class="plain-syntax">, </span><span class="identifier-syntax">pos</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">pos</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next_entry</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><a href="4-anl.html#SP7" class="function-link"><span class="function-syntax">ActionNameLists::join_to</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">pos</span><span class="plain-syntax">, </span><span class="identifier-syntax">new_entry</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="4-anl.html#SP9">&#167;9</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP10" class="paragraph-anchor"></a><b>&#167;10. </b>When not pruning the list, this macro is useful for working through it:
</p>

<pre class="definitions code-font"><span class="definition-keyword">define</span> <span class="identifier-syntax">LOOP_THROUGH_ANL</span><span class="plain-syntax">(</span><span class="identifier-syntax">var</span><span class="plain-syntax">, </span><span class="identifier-syntax">list</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">var</span><span class="plain-syntax"> = (</span><span class="identifier-syntax">list</span><span class="plain-syntax">)?(</span><span class="identifier-syntax">list</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">entries</span><span class="plain-syntax">):</span><span class="identifier-syntax">NULL</span><span class="plain-syntax">; </span><span class="identifier-syntax">var</span><span class="plain-syntax">; </span><span class="identifier-syntax">var</span><span class="plain-syntax"> = </span><span class="identifier-syntax">var</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next_entry</span><span class="plain-syntax">)</span>
</pre>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">ActionNameLists::length</span><button class="popup" onclick="togglePopup('usagePopup12')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup12">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::length</span></span>:<br/><a href="4-anl.html#SP11">&#167;11</a>, <a href="4-anl.html#SP23">&#167;23</a><br/>Parse Clauses - <a href="4-pc.html#SP1">&#167;1</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_name_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">list</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">C</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_THROUGH_ANL</span><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="identifier-syntax">list</span><span class="plain-syntax">) </span><span class="identifier-syntax">C</span><span class="plain-syntax">++;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">C</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">ActionNameLists::nonempty</span><button class="popup" onclick="togglePopup('usagePopup13')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup13">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::nonempty</span></span>:<br/>Action Patterns - <a href="4-ap2.html#SP7">&#167;7</a><br/>Parse Action Patterns - <a href="4-pap.html#SP5">&#167;5</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_name_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">list</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">list</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">list</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">entries</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP11" class="paragraph-anchor"></a><b>&#167;11. </b>If an action list is a wrapper for a single named action pattern, the
following function returns that NAP. Anything more complicated, <span class="extract"><span class="extract-syntax">NULL</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">named_action_pattern</span><span class="plain-syntax"> *</span><span class="function-syntax">ActionNameLists::is_single_NAP</span><button class="popup" onclick="togglePopup('usagePopup14')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup14">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::is_single_NAP</span></span>:<br/>Action Patterns - <a href="4-ap2.html#SP7">&#167;7</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_name_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">list</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><a href="4-anl.html#SP10" class="function-link"><span class="function-syntax">ActionNameLists::length</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">list</span><span class="plain-syntax">) == </span><span class="constant-syntax">1</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">list</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">negation_state</span><span class="plain-syntax"> == </span><span class="constant-syntax">ANL_POSITIVE</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">anl_item</span><span class="plain-syntax"> *</span><span class="identifier-syntax">item</span><span class="plain-syntax"> = </span><a href="4-anl.html#SP12" class="function-link"><span class="function-syntax">ActionNameLists::first_item</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">list</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">item</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">nap_listed</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP12" class="paragraph-anchor"></a><b>&#167;12. </b>The <a href="4-anl.html#SP12" class="internal">anl_item</a> material is the actual content we are trying to get at.
Like life, items are a mixture of naps and actions. At most one of these
fields is non-<span class="extract"><span class="extract-syntax">NULL</span></span>. If they are both <span class="extract"><span class="extract-syntax">NULL</span></span>, this represents "doing
anything" &mdash; a completely unrestricted action.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">anl_item</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">action_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">action_listed</span><span class="plain-syntax">; </span><span class="comment-syntax"> the action in this ANL list entry</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">named_action_pattern</span><span class="plain-syntax"> *</span><span class="identifier-syntax">nap_listed</span><span class="plain-syntax">; </span><span class="comment-syntax"> or a named pattern instead</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">anl_item</span><span class="plain-syntax">;</span>

<span class="reserved-syntax">anl_item</span><span class="plain-syntax"> </span><span class="function-syntax">ActionNameLists::new_item</span><button class="popup" onclick="togglePopup('usagePopup15')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup15">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::new_item</span></span>:<br/><a href="4-anl.html#SP4">&#167;4</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">void</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">anl_item</span><span class="plain-syntax"> </span><span class="identifier-syntax">item</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">item</span><span class="plain-syntax">.</span><span class="element-syntax">action_listed</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">item</span><span class="plain-syntax">.</span><span class="element-syntax">nap_listed</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">item</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">ActionNameLists::clear_item_data</span><button class="popup" onclick="togglePopup('usagePopup16')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup16">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::clear_item_data</span></span>:<br/><a href="4-anl.html#SP34_1_1">&#167;34.1.1</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="reserved-syntax">action_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">an</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">item</span><span class="plain-syntax">.</span><span class="element-syntax">action_listed</span><span class="plain-syntax"> = </span><span class="identifier-syntax">an</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">item</span><span class="plain-syntax">.</span><span class="element-syntax">nap_listed</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">anl_item</span><span class="plain-syntax"> *</span><span class="function-syntax">ActionNameLists::first_item</span><button class="popup" onclick="togglePopup('usagePopup17')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup17">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::first_item</span></span>:<br/><a href="4-anl.html#SP11">&#167;11</a>, <a href="4-anl.html#SP23">&#167;23</a><br/>Parse Clauses - <a href="4-pc.html#SP1_4">&#167;1.4</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_name_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">list</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">list</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">list</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">entries</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> &amp;(</span><span class="identifier-syntax">list</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">entries</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">item</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>The structure anl_item is accessed in 4/pc and here.</li></ul>
<p class="commentary firstcommentary"><a id="SP13" class="paragraph-anchor"></a><b>&#167;13. </b>The following is one of Inform's standardised comparison routines, which
takes a pair of objects A, B and returns 1 if A makes a more specific
description than B, 0 if they seem equally specific, or \(-1\) if B makes a
more specific description than A. This is transitive, and intended to be
used in sorting algorithms.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">ActionNameLists::compare_specificity</span><button class="popup" onclick="togglePopup('usagePopup18')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup18">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::compare_specificity</span></span>:<br/>Action Patterns - <a href="4-ap2.html#SP10">&#167;10</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_name_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">anl1</span><span class="plain-syntax">, </span><span class="reserved-syntax">action_name_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">anl2</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">count1</span><span class="plain-syntax">, </span><span class="identifier-syntax">count2</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">count1</span><span class="plain-syntax"> = </span><a href="4-anl.html#SP13" class="function-link"><span class="function-syntax">ActionNameLists::count_actions_covered</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">anl1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">count2</span><span class="plain-syntax"> = </span><a href="4-anl.html#SP13" class="function-link"><span class="function-syntax">ActionNameLists::count_actions_covered</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">anl2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">count1</span><span class="plain-syntax"> &lt; </span><span class="identifier-syntax">count2</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">count1</span><span class="plain-syntax"> &gt; </span><span class="identifier-syntax">count2</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> -1;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">ActionNameLists::count_actions_covered</span><span class="plain-syntax">(</span><span class="reserved-syntax">action_name_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">list</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">k</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">, </span><span class="identifier-syntax">infinity</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NUMBER_CREATED</span><span class="plain-syntax">(</span><span class="reserved-syntax">action_name</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">list</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">infinity</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">list</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">entries</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">infinity</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_THROUGH_ANL</span><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="identifier-syntax">list</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">item</span><span class="plain-syntax">.</span><span class="element-syntax">nap_listed</span><span class="plain-syntax">) </span><span class="reserved-syntax">continue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">item</span><span class="plain-syntax">.</span><span class="element-syntax">action_listed</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">k</span><span class="plain-syntax"> &lt; </span><span class="identifier-syntax">infinity</span><span class="plain-syntax">)) </span><span class="identifier-syntax">k</span><span class="plain-syntax">++;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">k</span><span class="plain-syntax"> = </span><span class="identifier-syntax">infinity</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="4-anl.html#SP2" class="function-link"><span class="function-syntax">ActionNameLists::positive</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">list</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) </span><span class="identifier-syntax">k</span><span class="plain-syntax"> = </span><span class="identifier-syntax">infinity</span><span class="plain-syntax"> - </span><span class="identifier-syntax">k</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">k</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">named_action_pattern</span><span class="plain-syntax"> *</span><span class="function-syntax">ActionNameLists::nap</span><button class="popup" onclick="togglePopup('usagePopup19')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup19">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::nap</span></span>:<br/>Parse Clauses - <a href="4-pc.html#SP1_3">&#167;1.3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">entry</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">entry</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">item</span><span class="plain-syntax">.</span><span class="element-syntax">nap_listed</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">action_name</span><span class="plain-syntax"> *</span><span class="function-syntax">ActionNameLists::action</span><button class="popup" onclick="togglePopup('usagePopup20')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup20">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::action</span></span>:<br/>Parse Clauses - <a href="4-pc.html#SP1_1">&#167;1.1</a>, <a href="4-pc.html#SP1_3">&#167;1.3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">entry</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">entry</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">item</span><span class="plain-syntax">.</span><span class="element-syntax">action_listed</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP14" class="paragraph-anchor"></a><b>&#167;14. </b>A given action <span class="extract"><span class="extract-syntax">an</span></span> falls within the context of this list if it appears
positively in the list, or negatively by not falling into a category excluded
by it; for example, "examining" falls within "examining something", and also
within "doing something other than looking at something" (a case of itemwise
negation) but not "doing something other than looking".
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">ActionNameLists::covers_action</span><button class="popup" onclick="togglePopup('usagePopup21')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup21">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::covers_action</span></span>:<br/>Action Patterns - <a href="4-ap2.html#SP7">&#167;7</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_name_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">list</span><span class="plain-syntax">, </span><span class="reserved-syntax">action_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">an</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_THROUGH_ANL</span><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="identifier-syntax">list</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">anl_item</span><span class="plain-syntax"> *</span><span class="identifier-syntax">item</span><span class="plain-syntax"> = &amp;(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">item</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">within</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">item</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">action_listed</span><span class="plain-syntax"> == </span><span class="identifier-syntax">an</span><span class="plain-syntax">) </span><span class="identifier-syntax">within</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">item</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">nap_listed</span><span class="plain-syntax">) </span><span class="identifier-syntax">within</span><span class="plain-syntax"> =</span>
<span class="plain-syntax">            </span><a href="4-nap.html#SP5" class="function-link"><span class="function-syntax">NamedActionPatterns::covers_action</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">item</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">nap_listed</span><span class="plain-syntax">, </span><span class="identifier-syntax">an</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (((</span><span class="identifier-syntax">within</span><span class="plain-syntax">) &amp;&amp; (</span><a href="4-anl.html#SP2" class="function-link"><span class="function-syntax">ActionNameLists::positive</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">list</span><span class="plain-syntax">))) ||</span>
<span class="plain-syntax">            ((</span><span class="identifier-syntax">within</span><span class="plain-syntax"> == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) &amp;&amp; (</span><a href="4-anl.html#SP2" class="function-link"><span class="function-syntax">ActionNameLists::positive</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">list</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">)))</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP15" class="paragraph-anchor"></a><b>&#167;15. </b>The <a href="4-anl.html#SP15" class="internal">anl_parsing_data</a> material is needed on a temporary basis when parsing
the text leading to a list:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">anl_parsing_data</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">word_position</span><span class="plain-syntax">; </span><span class="comment-syntax"> and some values used temporarily during parsing</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">abbreviation_level</span><span class="plain-syntax">; </span><span class="comment-syntax"> number of words missing</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">anl_clause</span><span class="plain-syntax"> *</span><span class="identifier-syntax">anl_clauses</span><span class="plain-syntax">; </span><span class="comment-syntax"> clauses in this reading</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">anl_parsing_data</span><span class="plain-syntax">;</span>

<span class="reserved-syntax">anl_parsing_data</span><span class="plain-syntax"> </span><span class="function-syntax">ActionNameLists::new_parsing_data</span><button class="popup" onclick="togglePopup('usagePopup22')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup22">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::new_parsing_data</span></span>:<br/><a href="4-anl.html#SP4">&#167;4</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">anl_parsing_data</span><span class="plain-syntax"> </span><span class="reserved-syntax">parsing_data</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">parsing_data</span><span class="plain-syntax">.</span><span class="element-syntax">anl_clauses</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">parsing_data</span><span class="plain-syntax">.</span><span class="element-syntax">abbreviation_level</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">parsing_data</span><span class="plain-syntax">.</span><span class="element-syntax">word_position</span><span class="plain-syntax"> = -1;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="reserved-syntax">parsing_data</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">ActionNameLists::clear_parsing_data</span><button class="popup" onclick="togglePopup('usagePopup23')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup23">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::clear_parsing_data</span></span>:<br/><a href="4-anl.html#SP34_1_1">&#167;34.1.1</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">W</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">parsing_data</span><span class="plain-syntax">.</span><span class="element-syntax">anl_clauses</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> = -1;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Wordings::nonempty</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">)) </span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Wordings::first_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">parsing_data</span><span class="plain-syntax">.</span><span class="element-syntax">word_position</span><span class="plain-syntax"> = </span><span class="identifier-syntax">at</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">parsing_data</span><span class="plain-syntax">.</span><span class="element-syntax">abbreviation_level</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>The structure anl_parsing_data is accessed in 4/pc and here.</li></ul>
<p class="commentary firstcommentary"><a id="SP16" class="paragraph-anchor"></a><b>&#167;16. </b>Parsing data contains a linked list, sorted in ascending clause ID order, of the
following structures, which are similar (but not identical) to <a href="4-apc.html#SP3" class="internal">ap_clause</a>
objects: and indeed, in the happy case where an entry in an action name list
produces a successful parse in <a href="4-pc.html" class="internal">Parse Clauses</a>, the <a href="4-anl.html#SP16" class="internal">anl_clause</a>
objects of that entry will be turned into a string of <a href="4-apc.html#SP3" class="internal">ap_clause</a> objects
in the final AP.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">anl_clause</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">clause_ID</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">clause_text</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">anl_clause</span><span class="plain-syntax"> *</span><span class="identifier-syntax">next_clause</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">shared_variable</span><span class="plain-syntax"> *</span><span class="identifier-syntax">stv_to_match</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">evaluation</span><span class="plain-syntax">;</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">anl_clause</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>The structure anl_clause is accessed in 4/apc, 4/pc, 4/gng and here.</li></ul>
<p class="commentary firstcommentary"><a id="SP17" class="paragraph-anchor"></a><b>&#167;17. </b>And this is convenient for looking through them:
</p>

<pre class="definitions code-font"><span class="definition-keyword">define</span> <span class="identifier-syntax">LOOP_THROUGH_ANL_CLAUSES</span><span class="plain-syntax">(</span><span class="identifier-syntax">c</span><span class="plain-syntax">, </span><span class="identifier-syntax">entry</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">anl_clause</span><span class="plain-syntax"> *</span><span class="identifier-syntax">c</span><span class="plain-syntax"> = (</span><span class="identifier-syntax">entry</span><span class="plain-syntax">)?(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">parsing_data</span><span class="plain-syntax">.</span><span class="element-syntax">anl_clauses</span><span class="plain-syntax">):</span><span class="identifier-syntax">NULL</span><span class="plain-syntax">; </span><span class="identifier-syntax">c</span><span class="plain-syntax">; </span><span class="identifier-syntax">c</span><span class="plain-syntax"> = </span><span class="identifier-syntax">c</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next_clause</span><span class="plain-syntax">)</span>
</pre>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">ActionNameLists::noun_count</span><button class="popup" onclick="togglePopup('usagePopup24')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup24">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::noun_count</span></span>:<br/><a href="4-anl.html#SP21">&#167;21</a><br/>Parse Clauses - <a href="4-pc.html#SP1_3">&#167;1.3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">entry</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">p</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_THROUGH_ANL_CLAUSES</span><span class="plain-syntax">(</span><span class="identifier-syntax">c</span><span class="plain-syntax">, </span><span class="identifier-syntax">entry</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">c</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_ID</span><span class="plain-syntax"> == </span><span class="constant-syntax">NOUN_AP_CLAUSE</span><span class="plain-syntax">) || (</span><span class="identifier-syntax">c</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_ID</span><span class="plain-syntax"> == </span><span class="constant-syntax">SECOND_AP_CLAUSE</span><span class="plain-syntax">))</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">p</span><span class="plain-syntax">++;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">p</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">ActionNameLists::has_clause</span><button class="popup" onclick="togglePopup('usagePopup25')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup25">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::has_clause</span></span>:<br/><a href="4-anl.html#SP36">&#167;36</a>, <a href="4-anl.html#SP41">&#167;41</a><br/>Going - <a href="4-gng.html#SP12">&#167;12</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">C</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_THROUGH_ANL_CLAUSES</span><span class="plain-syntax">(</span><span class="identifier-syntax">c</span><span class="plain-syntax">, </span><span class="identifier-syntax">entry</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_ID</span><span class="plain-syntax"> == </span><span class="identifier-syntax">C</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">anl_clause</span><span class="plain-syntax"> *</span><span class="function-syntax">ActionNameLists::get_clause</span><button class="popup" onclick="togglePopup('usagePopup26')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup26">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::get_clause</span></span>:<br/><a href="4-anl.html#SP41">&#167;41</a><br/>Going - <a href="4-gng.html#SP12">&#167;12</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">C</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_THROUGH_ANL_CLAUSES</span><span class="plain-syntax">(</span><span class="identifier-syntax">c</span><span class="plain-syntax">, </span><span class="identifier-syntax">entry</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_ID</span><span class="plain-syntax"> == </span><span class="identifier-syntax">C</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">c</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="function-syntax">ActionNameLists::get_clause_wording</span><button class="popup" onclick="togglePopup('usagePopup27')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup27">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::get_clause_wording</span></span>:<br/><a href="4-anl.html#SP35">&#167;35</a>, <a href="4-anl.html#SP36">&#167;36</a>, <a href="4-anl.html#SP37">&#167;37</a><br/>Going - <a href="4-gng.html#SP12">&#167;12</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">C</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_THROUGH_ANL_CLAUSES</span><span class="plain-syntax">(</span><span class="identifier-syntax">c</span><span class="plain-syntax">, </span><span class="identifier-syntax">entry</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_ID</span><span class="plain-syntax"> == </span><span class="identifier-syntax">C</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">c</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_text</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">EMPTY_WORDING</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP18" class="paragraph-anchor"></a><b>&#167;18. </b>Note that it is legal to create an ANL clause with empty wording.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="function-syntax">ActionNameLists::set_clause_wording</span><button class="popup" onclick="togglePopup('usagePopup28')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup28">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::set_clause_wording</span></span>:<br/><a href="4-anl.html#SP21">&#167;21</a>, <a href="4-anl.html#SP30_3">&#167;30.3</a>, <a href="4-anl.html#SP33">&#167;33</a>, <a href="4-anl.html#SP34_1_3">&#167;34.1.3</a>, <a href="4-anl.html#SP41">&#167;41</a><br/>Going - <a href="4-gng.html#SP12">&#167;12</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">C</span><span class="plain-syntax">, </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">W</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">entry</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"no entry"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">anl_clause</span><span class="plain-syntax"> *</span><span class="identifier-syntax">prev</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_THROUGH_ANL_CLAUSES</span><span class="plain-syntax">(</span><span class="identifier-syntax">c</span><span class="plain-syntax">, </span><span class="identifier-syntax">entry</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_ID</span><span class="plain-syntax"> == </span><span class="identifier-syntax">C</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">c</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_text</span><span class="plain-syntax"> = </span><span class="identifier-syntax">W</span><span class="plain-syntax">; </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">entry</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_ID</span><span class="plain-syntax"> &gt; </span><span class="identifier-syntax">C</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="4-anl.html#SP18_1" class="named-paragraph-link"><span class="named-paragraph">Insert clause here</span><span class="named-paragraph-number">18.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">prev</span><span class="plain-syntax"> = </span><span class="identifier-syntax">c</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">anl_clause</span><span class="plain-syntax"> *</span><span class="identifier-syntax">c</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="4-anl.html#SP18_1" class="named-paragraph-link"><span class="named-paragraph">Insert clause here</span><span class="named-paragraph-number">18.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP18_1" class="paragraph-anchor"></a><b>&#167;18.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Insert clause here</span><span class="named-paragraph-number">18.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">anl_clause</span><span class="plain-syntax"> *</span><span class="identifier-syntax">nc</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CREATE</span><span class="plain-syntax">(</span><span class="reserved-syntax">anl_clause</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">nc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_ID</span><span class="plain-syntax"> = </span><span class="identifier-syntax">C</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">nc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_text</span><span class="plain-syntax"> = </span><span class="identifier-syntax">W</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">nc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">evaluation</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">nc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">stv_to_match</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">prev</span><span class="plain-syntax">) { </span><span class="identifier-syntax">nc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next_clause</span><span class="plain-syntax"> = </span><span class="identifier-syntax">c</span><span class="plain-syntax">; </span><span class="identifier-syntax">prev</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next_clause</span><span class="plain-syntax"> = </span><span class="identifier-syntax">nc</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> { </span><span class="identifier-syntax">nc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next_clause</span><span class="plain-syntax"> = </span><span class="identifier-syntax">c</span><span class="plain-syntax">; </span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">parsing_data</span><span class="plain-syntax">.</span><span class="element-syntax">anl_clauses</span><span class="plain-syntax"> = </span><span class="identifier-syntax">nc</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">entry</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="4-anl.html#SP18">&#167;18</a> (twice).</li></ul>
<p class="commentary firstcommentary"><a id="SP19" class="paragraph-anchor"></a><b>&#167;19. </b>This is really the same function but setting variable as well as ID.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="function-syntax">ActionNameLists::set_clause_wording_and_stv</span><button class="popup" onclick="togglePopup('usagePopup29')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup29">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::set_clause_wording_and_stv</span></span>:<br/><a href="4-anl.html#SP26">&#167;26</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">C</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">W</span><span class="plain-syntax">, </span><span class="identifier-syntax">shared_variable</span><span class="plain-syntax"> *</span><span class="identifier-syntax">stv</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">entry</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"no entry"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">anl_clause</span><span class="plain-syntax"> *</span><span class="identifier-syntax">prev</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_THROUGH_ANL_CLAUSES</span><span class="plain-syntax">(</span><span class="identifier-syntax">c</span><span class="plain-syntax">, </span><span class="identifier-syntax">entry</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_ID</span><span class="plain-syntax"> == </span><span class="identifier-syntax">C</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">c</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_text</span><span class="plain-syntax"> = </span><span class="identifier-syntax">W</span><span class="plain-syntax">; </span><span class="identifier-syntax">c</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">stv_to_match</span><span class="plain-syntax"> = </span><span class="identifier-syntax">stv</span><span class="plain-syntax">; </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">entry</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_ID</span><span class="plain-syntax"> &gt; </span><span class="identifier-syntax">C</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="4-anl.html#SP19_1" class="named-paragraph-link"><span class="named-paragraph">Insert clause here with stv</span><span class="named-paragraph-number">19.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">prev</span><span class="plain-syntax"> = </span><span class="identifier-syntax">c</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">anl_clause</span><span class="plain-syntax"> *</span><span class="identifier-syntax">c</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="4-anl.html#SP19_1" class="named-paragraph-link"><span class="named-paragraph">Insert clause here with stv</span><span class="named-paragraph-number">19.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP19_1" class="paragraph-anchor"></a><b>&#167;19.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Insert clause here with stv</span><span class="named-paragraph-number">19.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">anl_clause</span><span class="plain-syntax"> *</span><span class="identifier-syntax">nc</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CREATE</span><span class="plain-syntax">(</span><span class="reserved-syntax">anl_clause</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">nc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_ID</span><span class="plain-syntax"> = </span><span class="identifier-syntax">C</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">nc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_text</span><span class="plain-syntax"> = </span><span class="identifier-syntax">W</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">nc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">evaluation</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">nc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">stv_to_match</span><span class="plain-syntax"> = </span><span class="identifier-syntax">stv</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">prev</span><span class="plain-syntax">) { </span><span class="identifier-syntax">nc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next_clause</span><span class="plain-syntax"> = </span><span class="identifier-syntax">c</span><span class="plain-syntax">; </span><span class="identifier-syntax">prev</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next_clause</span><span class="plain-syntax"> = </span><span class="identifier-syntax">nc</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> { </span><span class="identifier-syntax">nc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next_clause</span><span class="plain-syntax"> = </span><span class="identifier-syntax">c</span><span class="plain-syntax">; </span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">parsing_data</span><span class="plain-syntax">.</span><span class="element-syntax">anl_clauses</span><span class="plain-syntax"> = </span><span class="identifier-syntax">nc</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">entry</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="4-anl.html#SP19">&#167;19</a> (twice).</li></ul>
<p class="commentary firstcommentary"><a id="SP20" class="paragraph-anchor"></a><b>&#167;20. </b>This truncates a clause so that it stops just before the given word number.
For example, "croquet in the gardens" might be truncated to just "croquet".
Here, if the text should become empty as a result then the clause is deleted
from the list. This is important since it removes temporary <span class="extract"><span class="extract-syntax">TAIL_AP_CLAUSE</span></span>
clauses if they successfully convert into more permanent ones.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">ActionNameLists::truncate_clause</span><button class="popup" onclick="togglePopup('usagePopup30')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup30">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::truncate_clause</span></span>:<br/><a href="4-anl.html#SP41">&#167;41</a><br/>Going - <a href="4-gng.html#SP12">&#167;12</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">C</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">wn</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">anl_clause</span><span class="plain-syntax"> *</span><span class="identifier-syntax">prev</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_THROUGH_ANL_CLAUSES</span><span class="plain-syntax">(</span><span class="identifier-syntax">c</span><span class="plain-syntax">, </span><span class="identifier-syntax">entry</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_ID</span><span class="plain-syntax"> == </span><span class="identifier-syntax">C</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">c</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_text</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Wordings::up_to</span><span class="plain-syntax">(</span><span class="identifier-syntax">c</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_text</span><span class="plain-syntax">, </span><span class="identifier-syntax">wn</span><span class="plain-syntax"> - </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Wordings::empty</span><span class="plain-syntax">(</span><span class="identifier-syntax">c</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_text</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">prev</span><span class="plain-syntax">) </span><span class="identifier-syntax">prev</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next_clause</span><span class="plain-syntax"> = </span><span class="identifier-syntax">c</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next_clause</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">parsing_data</span><span class="plain-syntax">.</span><span class="element-syntax">anl_clauses</span><span class="plain-syntax"> = </span><span class="identifier-syntax">c</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next_clause</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">prev</span><span class="plain-syntax"> = </span><span class="identifier-syntax">c</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP21" class="paragraph-anchor"></a><b>&#167;21. </b>Up to two "nouns" can be added to an entry; the first to be added is put
into the <span class="extract"><span class="extract-syntax">NOUN_AP_CLAUSE</span></span> clause, and the second to <span class="extract"><span class="extract-syntax">SECOND_AP_CLAUSE</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="function-syntax">ActionNameLists::add_noun</span><button class="popup" onclick="togglePopup('usagePopup31')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup31">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::add_noun</span></span>:<br/><a href="4-anl.html#SP30_1">&#167;30.1</a>, <a href="4-anl.html#SP30_6">&#167;30.6</a>, <a href="4-anl.html#SP34_1_2">&#167;34.1.2</a>, <a href="4-anl.html#SP34_1_3">&#167;34.1.3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">W</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">switch</span><span class="plain-syntax"> (</span><a href="4-anl.html#SP17" class="function-link"><span class="function-syntax">ActionNameLists::noun_count</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="constant-syntax">0</span><span class="plain-syntax">: </span><a href="4-anl.html#SP18" class="function-link"><span class="function-syntax">ActionNameLists::set_clause_wording</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="constant-syntax">NOUN_AP_CLAUSE</span><span class="plain-syntax">, </span><span class="identifier-syntax">W</span><span class="plain-syntax">); </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span><span class="plain-syntax">: </span><a href="4-anl.html#SP18" class="function-link"><span class="function-syntax">ActionNameLists::set_clause_wording</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="constant-syntax">SECOND_AP_CLAUSE</span><span class="plain-syntax">, </span><span class="identifier-syntax">W</span><span class="plain-syntax">); </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">default:</span><span class="plain-syntax"> </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"too many nouns for ANL entry"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">entry</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP22" class="paragraph-anchor"></a><b>&#167;22. </b>So much for clauses. Entries also record the word position at which the
action (or named action pattern) text kicks in:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">ActionNameLists::word_position</span><button class="popup" onclick="togglePopup('usagePopup32')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup32">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::word_position</span></span>:<br/>Parse Clauses - <a href="4-pc.html#SP1_1">&#167;1.1</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">entry</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">entry</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">parsing_data</span><span class="plain-syntax">.</span><span class="element-syntax">word_position</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> -1;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP23" class="paragraph-anchor"></a><b>&#167;23. Single and best actions.</b>This tests whether the list gives a single positive action:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">action_name</span><span class="plain-syntax"> *</span><span class="function-syntax">ActionNameLists::single_positive_action</span><button class="popup" onclick="togglePopup('usagePopup33')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup33">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::single_positive_action</span></span>:<br/><a href="4-anl.html#SP24">&#167;24</a><br/>Action Patterns - <a href="4-ap2.html#SP7">&#167;7</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_name_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">list</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><a href="4-anl.html#SP10" class="function-link"><span class="function-syntax">ActionNameLists::length</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">list</span><span class="plain-syntax">) == </span><span class="constant-syntax">1</span><span class="plain-syntax">) &amp;&amp;</span>
<span class="plain-syntax">        (</span><a href="4-anl.html#SP2" class="function-link"><span class="function-syntax">ActionNameLists::positive</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">list</span><span class="plain-syntax">)))</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="4-anl.html#SP12" class="function-link"><span class="function-syntax">ActionNameLists::first_item</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">list</span><span class="plain-syntax">)-&gt;</span><span class="element-syntax">action_listed</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP24" class="paragraph-anchor"></a><b>&#167;24. </b>This is used only when the list is part of an exactly known action, so
that it should contain just one item, and this should be an actual action,
not a NAP.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">action_name</span><span class="plain-syntax"> *</span><span class="function-syntax">ActionNameLists::get_the_one_true_action</span><button class="popup" onclick="togglePopup('usagePopup34')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup34">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::get_the_one_true_action</span></span>:<br/>Explicit Actions - <a href="4-ea.html#SP2">&#167;2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_name_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">list</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">action_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">an</span><span class="plain-syntax"> = </span><a href="4-anl.html#SP23" class="function-link"><span class="function-syntax">ActionNameLists::single_positive_action</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">list</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">an</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"Singleton ANL points to null AN"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">an</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP25" class="paragraph-anchor"></a><b>&#167;25. </b>The "best" action is the one maximising the number of words in the fixed
part of an action name: thus if there are actions "throwing away" and
"throwing", then in the ANL arising from the text "throwing away the fish",
the action "throwing away" is better than the action "throwing".
</p>

<p class="commentary">This is easy to detect here, because the enforced ordering of the list ensures
that earlier entries are (in this sense) better than later ones.
</p>

<p class="commentary">If the list includes actions at two different word positions, so that they
are not alternate readings from the same point, then by definition there
is no best action. (For example, in "throwing or removing something".)
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">action_name</span><span class="plain-syntax"> *</span><span class="function-syntax">ActionNameLists::get_best_action</span><button class="popup" onclick="togglePopup('usagePopup35')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup35">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::get_best_action</span></span>:<br/>Actions - <a href="4-act.html#SP5">&#167;5</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_name_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">list</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="4-anl.html#SP2" class="function-link"><span class="function-syntax">ActionNameLists::positive</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">list</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">posn</span><span class="plain-syntax"> = -1;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">action_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">choice</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_THROUGH_ANL</span><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="identifier-syntax">list</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">item</span><span class="plain-syntax">.</span><span class="element-syntax">action_listed</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">parsing_data</span><span class="plain-syntax">.</span><span class="element-syntax">word_position</span><span class="plain-syntax"> != </span><span class="identifier-syntax">posn</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">posn</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">posn</span><span class="plain-syntax"> = </span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">parsing_data</span><span class="plain-syntax">.</span><span class="element-syntax">word_position</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">choice</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">choice</span><span class="plain-syntax"> = </span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">item</span><span class="plain-syntax">.</span><span class="element-syntax">action_listed</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">choice</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP26" class="paragraph-anchor"></a><b>&#167;26. Duplication.</b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="function-syntax">ActionNameLists::duplicate_entry</span><button class="popup" onclick="togglePopup('usagePopup36')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup36">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::duplicate_entry</span></span>:<br/><a href="4-anl.html#SP41">&#167;41</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">entry</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">new_entry</span><span class="plain-syntax"> = </span><a href="4-anl.html#SP4" class="function-link"><span class="function-syntax">ActionNameLists::new_entry_at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">EMPTY_WORDING</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">new_entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">parsing_data</span><span class="plain-syntax"> = </span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">parsing_data</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">new_entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">parsing_data</span><span class="plain-syntax">.</span><span class="element-syntax">anl_clauses</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_THROUGH_ANL_CLAUSES</span><span class="plain-syntax">(</span><span class="identifier-syntax">c</span><span class="plain-syntax">, </span><span class="identifier-syntax">entry</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><a href="4-anl.html#SP19" class="function-link"><span class="function-syntax">ActionNameLists::set_clause_wording_and_stv</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">new_entry</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">c</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_ID</span><span class="plain-syntax">, </span><span class="identifier-syntax">c</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_text</span><span class="plain-syntax">, </span><span class="identifier-syntax">c</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">stv_to_match</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">new_entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">item</span><span class="plain-syntax"> = </span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">item</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">new_entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next_entry</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">new_entry</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP27" class="paragraph-anchor"></a><b>&#167;27. Logging.</b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">ActionNameLists::log</span><button class="popup" onclick="togglePopup('usagePopup37')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup37">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::log</span></span>:<br/>IF Module - <a href="1-im.html#SP2">&#167;2</a>, <a href="1-im.html#SP2_2">&#167;2.2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_name_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">list</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">list</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;null-anl&gt;"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="4-anl.html#SP2" class="function-link"><span class="function-syntax">ActionNameLists::listwise_negated</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">list</span><span class="plain-syntax">)) { </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"L-NOT[\n"</span><span class="plain-syntax">); </span><span class="identifier-syntax">LOG_INDENT</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="4-anl.html#SP2" class="function-link"><span class="function-syntax">ActionNameLists::itemwise_negated</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">list</span><span class="plain-syntax">)) { </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"I-NOT[\n"</span><span class="plain-syntax">); </span><span class="identifier-syntax">LOG_INDENT</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">benchmark</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOOP_THROUGH_ANL</span><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="identifier-syntax">list</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">parsing_data</span><span class="plain-syntax">.</span><span class="element-syntax">word_position</span><span class="plain-syntax"> &lt; </span><span class="identifier-syntax">benchmark</span><span class="plain-syntax">) || (</span><span class="identifier-syntax">benchmark</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">))</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">benchmark</span><span class="plain-syntax"> = </span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">parsing_data</span><span class="plain-syntax">.</span><span class="element-syntax">word_position</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">c</span><span class="plain-syntax"> = </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOOP_THROUGH_ANL</span><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="identifier-syntax">list</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"(%d). +%d "</span><span class="plain-syntax">, </span><span class="identifier-syntax">c</span><span class="plain-syntax">, </span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">parsing_data</span><span class="plain-syntax">.</span><span class="element-syntax">word_position</span><span class="plain-syntax"> - </span><span class="identifier-syntax">benchmark</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><a href="4-anl.html#SP27" class="function-link"><span class="function-syntax">ActionNameLists::log_entry</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">c</span><span class="plain-syntax">++;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="4-anl.html#SP2" class="function-link"><span class="function-syntax">ActionNameLists::itemwise_negated</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">list</span><span class="plain-syntax">)) { </span><span class="identifier-syntax">LOG_OUTDENT</span><span class="plain-syntax">; </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"\n]\n"</span><span class="plain-syntax">); }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="4-anl.html#SP2" class="function-link"><span class="function-syntax">ActionNameLists::listwise_negated</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">list</span><span class="plain-syntax">)) { </span><span class="identifier-syntax">LOG_OUTDENT</span><span class="plain-syntax">; </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"\n]\n"</span><span class="plain-syntax">); }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">ActionNameLists::log_entry</span><button class="popup" onclick="togglePopup('usagePopup38')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup38">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::log_entry</span></span>:<br/><a href="4-anl.html#SP6">&#167;6</a><br/>IF Module - <a href="1-im.html#SP2">&#167;2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">entry</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">entry</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;null-entry&gt;"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">marked_for_deletion</span><span class="plain-syntax">) </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">" (to be deleted)"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><a href="4-anl.html#SP27" class="function-link"><span class="function-syntax">ActionNameLists::log_entry_briefly</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOOP_THROUGH_ANL_CLAUSES</span><span class="plain-syntax">(</span><span class="identifier-syntax">c</span><span class="plain-syntax">, </span><span class="identifier-syntax">entry</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Wordings::nonempty</span><span class="plain-syntax">(</span><span class="identifier-syntax">c</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_text</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">" "</span><span class="plain-syntax">); </span><a href="4-anl.html#SP27" class="function-link"><span class="function-syntax">ActionNameLists::log_clause</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">c</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">ActionNameLists::log_clause</span><button class="popup" onclick="togglePopup('usagePopup39')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup39">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::log_clause</span></span>:<br/>Parse Clauses - <a href="4-pc.html#SP1_1_1">&#167;1.1.1</a>, <a href="4-pc.html#SP1_1_2">&#167;1.1.2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">anl_clause</span><span class="plain-syntax"> *</span><span class="identifier-syntax">c</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"["</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="4-apc.html#SP2" class="function-link"><span class="function-syntax">APClauses::write_clause_ID</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">DL</span><span class="plain-syntax">, </span><span class="identifier-syntax">c</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_ID</span><span class="plain-syntax">, </span><span class="identifier-syntax">c</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">stv_to_match</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">": %W]"</span><span class="plain-syntax">, </span><span class="identifier-syntax">c</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_text</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">ActionNameLists::log_briefly</span><button class="popup" onclick="togglePopup('usagePopup40')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup40">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::log_briefly</span></span>:<br/>Action Patterns - <a href="4-ap2.html#SP5">&#167;5</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_name_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">list</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">list</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;null-anl&gt;"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="4-anl.html#SP2" class="function-link"><span class="function-syntax">ActionNameLists::listwise_negated</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">list</span><span class="plain-syntax">)) </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"L-NOT[ "</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="4-anl.html#SP2" class="function-link"><span class="function-syntax">ActionNameLists::itemwise_negated</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">list</span><span class="plain-syntax">)) </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"I-NOT[ "</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">c</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOOP_THROUGH_ANL</span><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="identifier-syntax">list</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">" / "</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><a href="4-anl.html#SP27" class="function-link"><span class="function-syntax">ActionNameLists::log_entry_briefly</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">c</span><span class="plain-syntax">++;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="4-anl.html#SP2" class="function-link"><span class="function-syntax">ActionNameLists::listwise_negated</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">list</span><span class="plain-syntax">)) </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">" ]"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">ActionNameLists::log_entry_briefly</span><span class="plain-syntax">(</span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">entry</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">item</span><span class="plain-syntax">.</span><span class="element-syntax">nap_listed</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"%W"</span><span class="plain-syntax">, </span><span class="identifier-syntax">Nouns::nominative_singular</span><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">item</span><span class="plain-syntax">.</span><span class="element-syntax">nap_listed</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">as_noun</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">item</span><span class="plain-syntax">.</span><span class="element-syntax">action_listed</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"ANY"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"%W"</span><span class="plain-syntax">, </span><a href="4-ann.html#SP5" class="function-link"><span class="function-syntax">ActionNameNames::tensed</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">item</span><span class="plain-syntax">.</span><span class="element-syntax">action_listed</span><span class="plain-syntax">, </span><span class="identifier-syntax">IS_TENSE</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">ActionNameLists::write_entry_briefly</span><button class="popup" onclick="togglePopup('usagePopup41')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup41">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::write_entry_briefly</span></span>:<br/><a href="4-anl.html#SP7">&#167;7</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">OUTPUT_STREAM</span><span class="plain-syntax">, </span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">entry</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">item</span><span class="plain-syntax">.</span><span class="element-syntax">nap_listed</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"%W"</span><span class="plain-syntax">, </span><span class="identifier-syntax">Nouns::nominative_singular</span><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">item</span><span class="plain-syntax">.</span><span class="element-syntax">nap_listed</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">as_noun</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">item</span><span class="plain-syntax">.</span><span class="element-syntax">action_listed</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"ANY"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"%W"</span><span class="plain-syntax">, </span><a href="4-ann.html#SP5" class="function-link"><span class="function-syntax">ActionNameNames::tensed</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">item</span><span class="plain-syntax">.</span><span class="element-syntax">action_listed</span><span class="plain-syntax">, </span><span class="identifier-syntax">IS_TENSE</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP28" class="paragraph-anchor"></a><b>&#167;28. Parsing text to an ANL.</b>Action name lists arise only for parsing text, and only from the function below;
this might match, for example, "doing something other than waiting", or
"dropping the box". We make no effort to understand the words which are not
part of the action: "dropping the box" is just "dropping (two words)" here.
</p>

<p class="commentary">Note that it works in either <span class="extract"><span class="extract-syntax">IS_TENSE</span></span> or <span class="extract"><span class="extract-syntax">HASBEEN_TENSE</span></span>, and that <span class="extract"><span class="extract-syntax">sense</span></span>
is set to <span class="extract"><span class="extract-syntax">FALSE</span></span> (if it is supplied) when the text had a negative sense &mdash;
something other than something &mdash; or <span class="extract"><span class="extract-syntax">TRUE</span></span> for a positive one.
</p>

<p class="commentary">The test group <span class="extract"><span class="extract-syntax">:actions</span></span> is helpful in catching errors here.
</p>

<p class="commentary firstcommentary"><a id="SP29" class="paragraph-anchor"></a><b>&#167;29. </b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">anl_parsing_tense</span><span class="plain-syntax"> = </span><span class="identifier-syntax">IS_TENSE</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">action_name_list</span><span class="plain-syntax"> *</span><span class="function-syntax">ActionNameLists::parse</span><button class="popup" onclick="togglePopup('usagePopup42')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup42">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::parse</span></span>:<br/><a href="4-anl.html#SP42">&#167;42</a><br/>Parse Action Patterns - <a href="4-pap.html#SP16">&#167;16</a><br/>Parse Clauses - <a href="4-pc.html#SP1">&#167;1</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">W</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">tense</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> *</span><span class="identifier-syntax">sense</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Wordings::mismatched_brackets</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">t</span><span class="plain-syntax"> = </span><span class="identifier-syntax">anl_parsing_tense</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">anl_parsing_tense</span><span class="plain-syntax"> = </span><span class="identifier-syntax">tense</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">r</span><span class="plain-syntax"> = </span><span class="function-syntax">&lt;action-list&gt;</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">anl_parsing_tense</span><span class="plain-syntax"> = </span><span class="identifier-syntax">t</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">r</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">sense</span><span class="plain-syntax">) *</span><span class="identifier-syntax">sense</span><span class="plain-syntax"> = </span><span class="function-syntax">&lt;&lt;r&gt;&gt;</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;&lt;rp&gt;&gt;</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP30" class="paragraph-anchor"></a><b>&#167;30. </b>The outer parts of the syntax are handled by a Preform grammar.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="function-syntax">&lt;action-list&gt;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">doing</span><span class="plain-syntax"> </span><span class="identifier-syntax">something</span><span class="plain-syntax">/</span><span class="identifier-syntax">anything</span><span class="plain-syntax"> </span><span class="identifier-syntax">other</span><span class="plain-syntax"> </span><span class="identifier-syntax">than</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;excluded-list&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">doing</span><span class="plain-syntax"> </span><span class="identifier-syntax">something</span><span class="plain-syntax">/</span><span class="identifier-syntax">anything</span><span class="plain-syntax"> </span><span class="identifier-syntax">except</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;excluded-list&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">doing</span><span class="plain-syntax"> </span><span class="identifier-syntax">something</span><span class="plain-syntax">/</span><span class="identifier-syntax">anything</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax">/</span><span class="identifier-syntax">with</span><span class="plain-syntax"> {...} |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">doing</span><span class="plain-syntax"> </span><span class="identifier-syntax">something</span><span class="plain-syntax">/</span><span class="identifier-syntax">anything</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">doing</span><span class="plain-syntax"> </span><span class="identifier-syntax">something</span><span class="plain-syntax">/</span><span class="identifier-syntax">anything</span><span class="plain-syntax"> {...} |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;anl&gt;</span>

<span class="function-syntax">&lt;excluded-list&gt;</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;anl&gt;</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax">/</span><span class="identifier-syntax">with</span><span class="plain-syntax"> {</span><span class="function-syntax">&lt;minimal-common-to-text&gt;</span><span class="plain-syntax">} |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;anl&gt;</span>

<span class="function-syntax">&lt;minimal-common-to-text&gt;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">_</span><span class="plain-syntax">,/</span><span class="identifier-syntax">or</span><span class="plain-syntax"> ... |</span>
<span class="plain-syntax">    ... </span><span class="identifier-syntax">to</span><span class="plain-syntax">/</span><span class="identifier-syntax">with</span><span class="plain-syntax"> ... |</span>
<span class="plain-syntax">    ...</span>
</pre>
<p class="commentary firstcommentary"><a id="SP30_1" class="paragraph-anchor"></a><b>&#167;30.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Something to</span><span class="named-paragraph-number">30.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">TW</span><span class="plain-syntax"> = </span><span class="identifier-syntax">GET_RW</span><span class="plain-syntax">(</span><span class="function-syntax">&lt;action-list&gt;</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">entry</span><span class="plain-syntax"> = </span><a href="4-anl.html#SP4" class="function-link"><span class="function-syntax">ActionNameLists::new_entry_at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="4-anl.html#SP21" class="function-link"><span class="function-syntax">ActionNameLists::add_noun</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="identifier-syntax">TW</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    ==&gt; { </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">, </span><a href="4-anl.html#SP1" class="function-link"><span class="function-syntax">ActionNameLists::new_list</span></a><span class="plain-syntax">(</span><a href="4-anl.html#SP35" class="function-link"><span class="function-syntax">ActionNameLists::ramify</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">), </span><span class="constant-syntax">ANL_POSITIVE</span><span class="plain-syntax">) }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="4-anl.html#SP30">&#167;30</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP30_2" class="paragraph-anchor"></a><b>&#167;30.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Something</span><span class="named-paragraph-number">30.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">entry</span><span class="plain-syntax"> = </span><a href="4-anl.html#SP4" class="function-link"><span class="function-syntax">ActionNameLists::new_entry_at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    ==&gt; { </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">, </span><a href="4-anl.html#SP1" class="function-link"><span class="function-syntax">ActionNameLists::new_list</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="constant-syntax">ANL_POSITIVE</span><span class="plain-syntax">) };</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="4-anl.html#SP30">&#167;30</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP30_3" class="paragraph-anchor"></a><b>&#167;30.3. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Something in</span><span class="named-paragraph-number">30.3</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">TW</span><span class="plain-syntax"> = </span><span class="identifier-syntax">GET_RW</span><span class="plain-syntax">(</span><span class="function-syntax">&lt;action-list&gt;</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">entry</span><span class="plain-syntax"> = </span><a href="4-anl.html#SP4" class="function-link"><span class="function-syntax">ActionNameLists::new_entry_at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="4-anl.html#SP18" class="function-link"><span class="function-syntax">ActionNameLists::set_clause_wording</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="constant-syntax">TAIL_AP_CLAUSE</span><span class="plain-syntax">, </span><span class="identifier-syntax">TW</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    ==&gt; { </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">, </span><a href="4-anl.html#SP1" class="function-link"><span class="function-syntax">ActionNameLists::new_list</span></a><span class="plain-syntax">(</span><a href="4-anl.html#SP35" class="function-link"><span class="function-syntax">ActionNameLists::ramify</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">), </span><span class="constant-syntax">ANL_POSITIVE</span><span class="plain-syntax">) };</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="4-anl.html#SP30">&#167;30</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP30_4" class="paragraph-anchor"></a><b>&#167;30.4. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">X</span><span class="named-paragraph-number">30.4</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    ==&gt; { </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">, </span><a href="4-anl.html#SP1" class="function-link"><span class="function-syntax">ActionNameLists::new_list</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">RP</span><span class="plain-syntax">[1], </span><span class="constant-syntax">ANL_POSITIVE</span><span class="plain-syntax">) };</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="4-anl.html#SP30">&#167;30</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP30_5" class="paragraph-anchor"></a><b>&#167;30.5. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Something except X</span><span class="named-paragraph-number">30.5</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    ==&gt; { </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">, </span><a href="4-anl.html#SP1" class="function-link"><span class="function-syntax">ActionNameLists::new_list</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">RP</span><span class="plain-syntax">[1], </span><span class="constant-syntax">ANL_NEGATED_LISTWISE</span><span class="plain-syntax">) };</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="4-anl.html#SP30">&#167;30</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP30_6" class="paragraph-anchor"></a><b>&#167;30.6. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Something except X with</span><span class="named-paragraph-number">30.6</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">entry</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RP</span><span class="plain-syntax">[1];</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">entry</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) ||</span>
<span class="plain-syntax">        (</span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">item</span><span class="plain-syntax">.</span><span class="element-syntax">action_listed</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) ||</span>
<span class="plain-syntax">        (</span><a href="4-as.html#SP4" class="function-link"><span class="function-syntax">ActionSemantics::can_have_noun</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">item</span><span class="plain-syntax">.</span><span class="element-syntax">action_listed</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        ==&gt; { </span><span class="identifier-syntax">fail</span><span class="plain-syntax"> </span><span class="identifier-syntax">production</span><span class="plain-syntax"> };</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><a href="4-anl.html#SP21" class="function-link"><span class="function-syntax">ActionNameLists::add_noun</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="identifier-syntax">GET_RW</span><span class="plain-syntax">(</span><span class="function-syntax">&lt;excluded-list&gt;</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    ==&gt; { </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">, </span><a href="4-anl.html#SP1" class="function-link"><span class="function-syntax">ActionNameLists::new_list</span></a><span class="plain-syntax">(</span><a href="4-anl.html#SP35" class="function-link"><span class="function-syntax">ActionNameLists::ramify</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">), </span><span class="constant-syntax">ANL_NEGATED_ITEMWISE</span><span class="plain-syntax">) };</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="4-anl.html#SP30">&#167;30</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP31" class="paragraph-anchor"></a><b>&#167;31. </b>This matches a comma/or-separated list of items:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="function-syntax">&lt;anl&gt;</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;anl-entry&gt;</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;anl-tail&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;anl-entry&gt;</span>

<span class="function-syntax">&lt;anl-tail&gt;</span>
<span class="plain-syntax">    , </span><span class="identifier-syntax">_or</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;anl&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">_</span><span class="plain-syntax">,/</span><span class="identifier-syntax">or</span><span class="plain-syntax"> </span><span class="function-syntax">&lt;anl&gt;</span>
</pre>
<p class="commentary firstcommentary"><a id="SP32" class="paragraph-anchor"></a><b>&#167;32. </b>Items can be named action patterns, so let's get those out of the way first:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="function-syntax">&lt;anl-entry&gt;</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;named-action-pattern&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;named-action-pattern-tailed&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;anl-entry-with-action&gt;</span>

<span class="function-syntax">&lt;named-action-pattern-tailed&gt;</span><span class="plain-syntax"> </span><span class="identifier-syntax">internal</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">=</span><span class="identifier-syntax">Wordings::first_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">); </span><span class="identifier-syntax">i</span><span class="plain-syntax">&lt;= </span><span class="identifier-syntax">Wordings::last_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">) - </span><span class="constant-syntax">1</span><span class="plain-syntax">; </span><span class="identifier-syntax">i</span><span class="plain-syntax">++) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="function-syntax">&lt;named-action-pattern&gt;</span><span class="plain-syntax">(</span><span class="identifier-syntax">Wordings::up_to</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">, </span><span class="identifier-syntax">i</span><span class="plain-syntax">))) {</span>
<span class="plain-syntax">            ==&gt; { -, </span><a href="4-anl.html#SP33" class="function-link"><span class="function-syntax">ActionNameLists::nap_entry</span></a><span class="plain-syntax">(</span><span class="function-syntax">&lt;&lt;rp&gt;&gt;</span><span class="plain-syntax">, </span><span class="identifier-syntax">W</span><span class="plain-syntax">, </span><span class="identifier-syntax">Wordings::from</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">, </span><span class="identifier-syntax">i</span><span class="plain-syntax">+1)) };</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP33" class="paragraph-anchor"></a><b>&#167;33. </b>Here <span class="extract"><span class="extract-syntax">TW</span></span> is the "tail wording", that is, any text left over after the name
itself. So, for "irreverent behaviour in the presence of the Bishop", the
<span class="extract"><span class="extract-syntax">nap</span></span> may be the "irreverent behaviour", and <span class="extract"><span class="extract-syntax">TW</span></span> the text "in the presence
of the Bishop". We put that temporarily into the <span class="extract"><span class="extract-syntax">TAIL_AP_CLAUSE</span></span>, and then
ramify what had been a single-entry list so that it may now have multiple
entries &mdash; for example, "irreverent behaviour [in: the presence of the Bishop]"
or "irreverent behaviour [in-presence: the Bishop]".
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="function-syntax">ActionNameLists::nap_entry</span><button class="popup" onclick="togglePopup('usagePopup43')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup43">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::nap_entry</span></span>:<br/><a href="4-anl.html#SP32">&#167;32</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">named_action_pattern</span><span class="plain-syntax"> *</span><span class="identifier-syntax">nap</span><span class="plain-syntax">, </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">W</span><span class="plain-syntax">, </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">TW</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">entry</span><span class="plain-syntax"> = </span><a href="4-anl.html#SP4" class="function-link"><span class="function-syntax">ActionNameLists::new_entry_at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">item</span><span class="plain-syntax">.</span><span class="element-syntax">nap_listed</span><span class="plain-syntax"> = </span><span class="identifier-syntax">nap</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Wordings::nonempty</span><span class="plain-syntax">(</span><span class="identifier-syntax">TW</span><span class="plain-syntax">))</span>
<span class="plain-syntax">        </span><a href="4-anl.html#SP18" class="function-link"><span class="function-syntax">ActionNameLists::set_clause_wording</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="constant-syntax">TAIL_AP_CLAUSE</span><span class="plain-syntax">, </span><span class="identifier-syntax">TW</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="4-anl.html#SP35" class="function-link"><span class="function-syntax">ActionNameLists::ramify</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP34" class="paragraph-anchor"></a><b>&#167;34. </b>If we aren't going to name an action pattern, we're going to have to spell
out an actual choice of action.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="function-syntax">&lt;anl-entry-with-action&gt;</span><span class="plain-syntax"> </span><span class="identifier-syntax">internal</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">results</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="4-anl.html#SP34_1" class="named-paragraph-link"><span class="named-paragraph">Parse the wording into a list of results</span><span class="named-paragraph-number">34.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">results</span><span class="plain-syntax"> = </span><a href="4-anl.html#SP35" class="function-link"><span class="function-syntax">ActionNameLists::ramify</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">results</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">results</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        ==&gt; { -, </span><span class="identifier-syntax">results</span><span class="plain-syntax"> }; </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    ==&gt; { </span><span class="identifier-syntax">fail</span><span class="plain-syntax"> </span><span class="identifier-syntax">nonterminal</span><span class="plain-syntax"> };</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP34_1" class="paragraph-anchor"></a><b>&#167;34.1. </b>The following makes a list of results before ramification.
</p>

<p class="commentary">For example, for the text "looking or taking inventory in the presence of Hans
in the Laboratory", we get the following set of <span class="extract"><span class="extract-syntax">results</span></span>:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">(1). +2 </span><span class="identifier-syntax">taking</span><span class="plain-syntax"> </span><span class="identifier-syntax">inventory</span><span class="plain-syntax"> [</span><span class="identifier-syntax">tail:</span><span class="plain-syntax"> </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">presence</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">hans</span><span class="plain-syntax"> </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">laboratory</span><span class="plain-syntax">]</span>
<span class="plain-syntax">(2). +2 </span><span class="identifier-syntax">taking</span><span class="plain-syntax"> [</span><span class="identifier-syntax">noun:</span><span class="plain-syntax"> </span><span class="identifier-syntax">inventory</span><span class="plain-syntax"> </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">presence</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">hans</span><span class="plain-syntax"> </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">laboratory</span><span class="plain-syntax">]</span>
<span class="plain-syntax">(3). +0 </span><span class="identifier-syntax">looking</span>
</pre>
<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Parse the wording into a list of results</span><span class="named-paragraph-number">34.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">trial_entry</span><span class="plain-syntax"> = </span><a href="4-anl.html#SP4" class="function-link"><span class="function-syntax">ActionNameLists::new_entry_at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">EMPTY_WORDING</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">action_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">an</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_OVER</span><span class="plain-syntax">(</span><span class="identifier-syntax">an</span><span class="plain-syntax">, </span><span class="reserved-syntax">action_name</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="4-anl.html#SP34_1_1" class="named-paragraph-link"><span class="named-paragraph">Ready the trial entry for another test</span><span class="named-paragraph-number">34.1.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">RW</span><span class="plain-syntax"> = </span><span class="identifier-syntax">EMPTY_WORDING</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">abbreviated_to_tail</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="4-anl.html#SP34_1_2" class="named-paragraph-link"><span class="named-paragraph">Make the trial entry fit this action, if possible, leaving remaining text in RW</span><span class="named-paragraph-number">34.1.2</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="4-anl.html#SP34_1_3" class="named-paragraph-link"><span class="named-paragraph">Transfer remaining words to a trailing clause</span><span class="named-paragraph-number">34.1.3</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="4-anl.html#SP34_1_4" class="named-paragraph-link"><span class="named-paragraph">Include the trial entry</span><span class="named-paragraph-number">34.1.4</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">NoMatch:</span><span class="plain-syntax"> ;</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="4-anl.html#SP34">&#167;34</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP34_1_1" class="paragraph-anchor"></a><b>&#167;34.1.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Ready the trial entry for another test</span><span class="named-paragraph-number">34.1.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">trial_entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next_entry</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><a href="4-anl.html#SP12" class="function-link"><span class="function-syntax">ActionNameLists::clear_item_data</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">trial_entry</span><span class="plain-syntax">, </span><span class="identifier-syntax">an</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="4-anl.html#SP15" class="function-link"><span class="function-syntax">ActionNameLists::clear_parsing_data</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">trial_entry</span><span class="plain-syntax">, </span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="4-anl.html#SP34_1">&#167;34.1</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP34_1_2" class="paragraph-anchor"></a><b>&#167;34.1.2. </b>Here <span class="extract"><span class="extract-syntax">XW</span></span> will be the wording of the action name, say "removing it from";
we try to fit <span class="extract"><span class="extract-syntax">W</span></span> to this, say "removing a heavy thing from something in the
Dining Room"; and if we cannot, we run away to the label <span class="extract"><span class="extract-syntax">NoMatch</span></span>, which is
inelegant, but there's no elegant way to break out of nested loops in C.
</p>

<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Make the trial entry fit this action, if possible, leaving remaining text in RW</span><span class="named-paragraph-number">34.1.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">x_ended</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">it_optional</span><span class="plain-syntax"> = </span><a href="4-ann.html#SP8" class="function-link"><span class="function-syntax">ActionNameNames::it_optional</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">an</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">abbreviable</span><span class="plain-syntax"> = </span><a href="4-ann.html#SP8" class="function-link"><span class="function-syntax">ActionNameNames::abbreviable</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">an</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">XW</span><span class="plain-syntax"> = </span><a href="4-ann.html#SP5" class="function-link"><span class="function-syntax">ActionNameNames::tensed</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">an</span><span class="plain-syntax">, </span><span class="identifier-syntax">anl_parsing_tense</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">w_m</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Wordings::first_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">), </span><span class="identifier-syntax">x_m</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Wordings::first_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">XW</span><span class="plain-syntax">), </span><span class="identifier-syntax">n</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">while</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">w_m</span><span class="plain-syntax"> &lt;= </span><span class="identifier-syntax">Wordings::last_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">)) &amp;&amp; (</span><span class="identifier-syntax">x_m</span><span class="plain-syntax"> &lt;= </span><span class="identifier-syntax">Wordings::last_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">XW</span><span class="plain-syntax">))) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Lexer::word</span><span class="plain-syntax">(</span><span class="identifier-syntax">x_m</span><span class="plain-syntax">++) != </span><span class="identifier-syntax">Lexer::word</span><span class="plain-syntax">(</span><span class="identifier-syntax">w_m</span><span class="plain-syntax">++)) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">abbreviable</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">it_optional</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">n</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">1</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">x_ended</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">; </span><span class="identifier-syntax">abbreviated_to_tail</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">; </span><span class="identifier-syntax">x_m</span><span class="plain-syntax">--; </span><span class="identifier-syntax">w_m</span><span class="plain-syntax">--;</span>
<span class="plain-syntax">            } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">goto</span><span class="plain-syntax"> </span><span class="identifier-syntax">NoMatch</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">n</span><span class="plain-syntax">++;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">x_m</span><span class="plain-syntax"> &gt; </span><span class="identifier-syntax">Wordings::last_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">XW</span><span class="plain-syntax">)) { </span><span class="identifier-syntax">x_ended</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">; </span><span class="reserved-syntax">break</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="function-syntax">&lt;object-pronoun&gt;</span><span class="plain-syntax">(</span><span class="identifier-syntax">Wordings::one_word</span><span class="plain-syntax">(</span><span class="identifier-syntax">x_m</span><span class="plain-syntax">))) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">w_m</span><span class="plain-syntax"> &gt; </span><span class="identifier-syntax">Wordings::last_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">)) </span><span class="identifier-syntax">x_ended</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">; </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">j</span><span class="plain-syntax"> = -1, </span><span class="identifier-syntax">k</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">k</span><span class="plain-syntax">=(</span><span class="identifier-syntax">it_optional</span><span class="plain-syntax">)?(</span><span class="identifier-syntax">w_m</span><span class="plain-syntax">):(</span><span class="identifier-syntax">w_m</span><span class="plain-syntax">+1); </span><span class="identifier-syntax">k</span><span class="plain-syntax">&lt;=</span><span class="identifier-syntax">Wordings::last_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">); </span><span class="identifier-syntax">k</span><span class="plain-syntax">++)</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Lexer::word</span><span class="plain-syntax">(</span><span class="identifier-syntax">k</span><span class="plain-syntax">) == </span><span class="identifier-syntax">Lexer::word</span><span class="plain-syntax">(</span><span class="identifier-syntax">x_m</span><span class="plain-syntax">+1)) { </span><span class="identifier-syntax">j</span><span class="plain-syntax"> = </span><span class="identifier-syntax">k</span><span class="plain-syntax">; </span><span class="reserved-syntax">break</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">j</span><span class="plain-syntax">&lt;0) </span><span class="reserved-syntax">goto</span><span class="plain-syntax"> </span><span class="identifier-syntax">NoMatch</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">j</span><span class="plain-syntax">-1 &gt;= </span><span class="identifier-syntax">w_m</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                    </span><a href="4-anl.html#SP21" class="function-link"><span class="function-syntax">ActionNameLists::add_noun</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">trial_entry</span><span class="plain-syntax">, </span><span class="identifier-syntax">Wordings::new</span><span class="plain-syntax">(</span><span class="identifier-syntax">w_m</span><span class="plain-syntax">, </span><span class="identifier-syntax">j</span><span class="plain-syntax">-1));</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">else</span>
<span class="plain-syntax">                    </span><a href="4-anl.html#SP21" class="function-link"><span class="function-syntax">ActionNameLists::add_noun</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">trial_entry</span><span class="plain-syntax">, </span><span class="identifier-syntax">EMPTY_WORDING</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">w_m</span><span class="plain-syntax"> = </span><span class="identifier-syntax">j</span><span class="plain-syntax">; </span><span class="identifier-syntax">x_m</span><span class="plain-syntax">++;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">x_ended</span><span class="plain-syntax">) </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">w_m</span><span class="plain-syntax"> &gt; </span><span class="identifier-syntax">Wordings::last_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">)) &amp;&amp; (</span><span class="identifier-syntax">x_ended</span><span class="plain-syntax"> == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">abbreviable</span><span class="plain-syntax">) </span><span class="identifier-syntax">x_ended</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">; </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">goto</span><span class="plain-syntax"> </span><span class="identifier-syntax">NoMatch</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">x_m</span><span class="plain-syntax"> &lt;= </span><span class="identifier-syntax">Wordings::last_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">XW</span><span class="plain-syntax">))</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">trial_entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">parsing_data</span><span class="plain-syntax">.</span><span class="element-syntax">abbreviation_level</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Wordings::last_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">XW</span><span class="plain-syntax">)-</span><span class="identifier-syntax">x_m</span><span class="plain-syntax">+1;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">RW</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Wordings::from</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">, </span><span class="identifier-syntax">w_m</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="4-anl.html#SP34_1">&#167;34.1</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP34_1_3" class="paragraph-anchor"></a><b>&#167;34.1.3. </b>For example, in "looking or taking inventory in the presence of Hans
in the Laboratory", after finding "taking inventory" as a possible action,
we are left with "in the presence of Hans in the Laboratory". These have to
be stored into <span class="extract"><span class="extract-syntax">TAIL_AP_CLAUSE</span></span>, since they cannot be part of any noun &mdash;
because taking inventory doesn't have a noun. But when finding "taking",
the remaining words "inventory in the presence of Hans in the Laboratory"
have to go into <span class="extract"><span class="extract-syntax">NOUN_AP_CLAUSE</span></span> &mdash; the taking action does have a noun.
</p>

<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Transfer remaining words to a trailing clause</span><span class="named-paragraph-number">34.1.3</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Wordings::nonempty</span><span class="plain-syntax">(</span><span class="identifier-syntax">RW</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><a href="4-as.html#SP4" class="function-link"><span class="function-syntax">ActionSemantics::can_have_noun</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">an</span><span class="plain-syntax">)) &amp;&amp; (</span><span class="identifier-syntax">abbreviated_to_tail</span><span class="plain-syntax"> == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">            </span><a href="4-anl.html#SP21" class="function-link"><span class="function-syntax">ActionNameLists::add_noun</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">trial_entry</span><span class="plain-syntax">, </span><span class="identifier-syntax">RW</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">            </span><a href="4-anl.html#SP18" class="function-link"><span class="function-syntax">ActionNameLists::set_clause_wording</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">trial_entry</span><span class="plain-syntax">, </span><span class="constant-syntax">TAIL_AP_CLAUSE</span><span class="plain-syntax">, </span><span class="identifier-syntax">RW</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="4-anl.html#SP34_1">&#167;34.1</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP34_1_4" class="paragraph-anchor"></a><b>&#167;34.1.4. </b>So this is the happy ending. We don't copy the trial entry; we insertion-sort
the structure itself into the results list, and make a fresh structure to be
the trial entry for future trials.
</p>

<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Include the trial entry</span><span class="named-paragraph-number">34.1.4</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">results</span><span class="plain-syntax"> = </span><a href="4-anl.html#SP9" class="function-link"><span class="function-syntax">ActionNameLists::join_entries</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">trial_entry</span><span class="plain-syntax">, </span><span class="identifier-syntax">results</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">trial_entry</span><span class="plain-syntax"> = </span><a href="4-anl.html#SP4" class="function-link"><span class="function-syntax">ActionNameLists::new_entry_at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">EMPTY_WORDING</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="4-anl.html#SP34_1">&#167;34.1</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP35" class="paragraph-anchor"></a><b>&#167;35. </b>And now we get to ramification. This is what happens last, when a set of
raw results has been produced. We "ramify" this by expanding it into multiple
readings according to how the trailing clause might in fact be made up of
sub-clauses. For example, our unramified set of results
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">(1). +2 </span><span class="identifier-syntax">taking</span><span class="plain-syntax"> </span><span class="identifier-syntax">inventory</span><span class="plain-syntax"> [</span><span class="identifier-syntax">tail:</span><span class="plain-syntax"> </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">presence</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">hans</span><span class="plain-syntax"> </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">laboratory</span><span class="plain-syntax">]</span>
<span class="plain-syntax">(2). +2 </span><span class="identifier-syntax">taking</span><span class="plain-syntax"> [</span><span class="identifier-syntax">noun:</span><span class="plain-syntax"> </span><span class="identifier-syntax">inventory</span><span class="plain-syntax"> </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">presence</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">hans</span><span class="plain-syntax"> </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">laboratory</span><span class="plain-syntax">]</span>
<span class="plain-syntax">(3). +0 </span><span class="identifier-syntax">looking</span>
</pre>
<p class="commentary">becomes the ramified set
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">(1). +2 </span><span class="identifier-syntax">taking</span><span class="plain-syntax"> </span><span class="identifier-syntax">inventory</span><span class="plain-syntax"> [</span><span class="identifier-syntax">in:</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">laboratory</span><span class="plain-syntax">] [</span><span class="identifier-syntax">in</span><span class="plain-syntax">-</span><span class="identifier-syntax">presence:</span><span class="plain-syntax"> </span><span class="identifier-syntax">hans</span><span class="plain-syntax">]</span>
<span class="plain-syntax">(2). +2 </span><span class="identifier-syntax">taking</span><span class="plain-syntax"> </span><span class="identifier-syntax">inventory</span><span class="plain-syntax"> [</span><span class="identifier-syntax">in</span><span class="plain-syntax">-</span><span class="identifier-syntax">presence:</span><span class="plain-syntax"> </span><span class="identifier-syntax">hans</span><span class="plain-syntax"> </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">laboratory</span><span class="plain-syntax">]</span>
<span class="plain-syntax">(3). +2 </span><span class="identifier-syntax">taking</span><span class="plain-syntax"> [</span><span class="identifier-syntax">noun:</span><span class="plain-syntax"> </span><span class="identifier-syntax">inventory</span><span class="plain-syntax">] [</span><span class="identifier-syntax">in:</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">laboratory</span><span class="plain-syntax">] [</span><span class="identifier-syntax">in</span><span class="plain-syntax">-</span><span class="identifier-syntax">presence:</span><span class="plain-syntax"> </span><span class="identifier-syntax">hans</span><span class="plain-syntax">]</span>
<span class="plain-syntax">(4). +2 </span><span class="identifier-syntax">taking</span><span class="plain-syntax"> [</span><span class="identifier-syntax">noun:</span><span class="plain-syntax"> </span><span class="identifier-syntax">inventory</span><span class="plain-syntax">] [</span><span class="identifier-syntax">in</span><span class="plain-syntax">-</span><span class="identifier-syntax">presence:</span><span class="plain-syntax"> </span><span class="identifier-syntax">hans</span><span class="plain-syntax"> </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">laboratory</span><span class="plain-syntax">]</span>
<span class="plain-syntax">(5). +2 </span><span class="identifier-syntax">taking</span><span class="plain-syntax"> [</span><span class="identifier-syntax">noun:</span><span class="plain-syntax"> </span><span class="identifier-syntax">inventory</span><span class="plain-syntax"> </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">presence</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">hans</span><span class="plain-syntax">] [</span><span class="identifier-syntax">in:</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">laboratory</span><span class="plain-syntax">]</span>
<span class="plain-syntax">(6). +2 </span><span class="identifier-syntax">taking</span><span class="plain-syntax"> [</span><span class="identifier-syntax">noun:</span><span class="plain-syntax"> </span><span class="identifier-syntax">inventory</span><span class="plain-syntax"> </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">presence</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">hans</span><span class="plain-syntax"> </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">laboratory</span><span class="plain-syntax">]</span>
<span class="plain-syntax">(7). +0 </span><span class="identifier-syntax">looking</span>
</pre>
<p class="commentary">Note that the <span class="extract"><span class="extract-syntax">TAIL_AP_CLAUSE</span></span> clauses, which were just temporary holders
for leftover text, have gone entirely. Had it been impossible to break them
into legal subclauses, they would have caused the result to be struck out
altogether. For example, this:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">(1). +0 </span><span class="identifier-syntax">taking</span><span class="plain-syntax"> </span><span class="identifier-syntax">inventory</span><span class="plain-syntax"> [</span><span class="identifier-syntax">tail:</span><span class="plain-syntax"> </span><span class="identifier-syntax">book</span><span class="plain-syntax">]</span>
<span class="plain-syntax">(2). +0 </span><span class="identifier-syntax">taking</span><span class="plain-syntax"> [</span><span class="identifier-syntax">noun:</span><span class="plain-syntax"> </span><span class="identifier-syntax">inventory</span><span class="plain-syntax"> </span><span class="identifier-syntax">book</span><span class="plain-syntax">]</span>
</pre>
<p class="commentary">ramifies to just
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">(1). +0 </span><span class="identifier-syntax">taking</span><span class="plain-syntax"> [</span><span class="identifier-syntax">noun:</span><span class="plain-syntax"> </span><span class="identifier-syntax">inventory</span><span class="plain-syntax"> </span><span class="identifier-syntax">book</span><span class="plain-syntax">]</span>
</pre>
<p class="commentary">because the tail wording "book" after "taking inventory" cannot be read as
a sequence of subclauses.
</p>

<p class="commentary">Ramification thus consists of a sudden increase in the number of possible
readings, which we call an explosion, followed by a cull of anything which
still has a <span class="extract"><span class="extract-syntax">TAIL_AP_CLAUSE</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="function-syntax">ActionNameLists::ramify</span><button class="popup" onclick="togglePopup('usagePopup44')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup44">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::ramify</span></span>:<br/><a href="4-anl.html#SP30_1">&#167;30.1</a>, <a href="4-anl.html#SP30_3">&#167;30.3</a>, <a href="4-anl.html#SP30_6">&#167;30.6</a>, <a href="4-anl.html#SP33">&#167;33</a>, <a href="4-anl.html#SP34">&#167;34</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">results</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">entry</span><span class="plain-syntax"> = </span><span class="identifier-syntax">results</span><span class="plain-syntax">; </span><span class="identifier-syntax">entry</span><span class="plain-syntax">; ) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">next</span><span class="plain-syntax"> = </span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next_entry</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><a href="4-anl.html#SP36" class="function-link"><span class="function-syntax">ActionNameLists::explode</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">entry</span><span class="plain-syntax"> = </span><span class="identifier-syntax">next</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">prev</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, *</span><span class="identifier-syntax">entry</span><span class="plain-syntax"> = </span><span class="identifier-syntax">results</span><span class="plain-syntax">; </span><span class="identifier-syntax">entry</span><span class="plain-syntax">; </span><span class="identifier-syntax">entry</span><span class="plain-syntax"> = </span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next_entry</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Wordings::nonempty</span><span class="plain-syntax">(</span><a href="4-anl.html#SP17" class="function-link"><span class="function-syntax">ActionNameLists::get_clause_wording</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="constant-syntax">TAIL_AP_CLAUSE</span><span class="plain-syntax">))) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">prev</span><span class="plain-syntax">) </span><span class="identifier-syntax">prev</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next_entry</span><span class="plain-syntax"> = </span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next_entry</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">results</span><span class="plain-syntax"> = </span><span class="identifier-syntax">entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next_entry</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">prev</span><span class="plain-syntax"> = </span><span class="identifier-syntax">entry</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">results</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP36" class="paragraph-anchor"></a><b>&#167;36. </b>And here is the explosion part. <span class="extract"><span class="extract-syntax">tc</span></span> here identifies what the trailing clause
actually is:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">ActionNameLists::explode</span><button class="popup" onclick="togglePopup('usagePopup45')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup45">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::explode</span></span>:<br/><a href="4-anl.html#SP35">&#167;35</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">entry</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">tc</span><span class="plain-syntax"> = -1;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="4-anl.html#SP17" class="function-link"><span class="function-syntax">ActionNameLists::has_clause</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="constant-syntax">TAIL_AP_CLAUSE</span><span class="plain-syntax">)) </span><span class="identifier-syntax">tc</span><span class="plain-syntax"> = </span><span class="constant-syntax">TAIL_AP_CLAUSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="4-anl.html#SP17" class="function-link"><span class="function-syntax">ActionNameLists::has_clause</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="constant-syntax">SECOND_AP_CLAUSE</span><span class="plain-syntax">)) </span><span class="identifier-syntax">tc</span><span class="plain-syntax"> = </span><span class="constant-syntax">SECOND_AP_CLAUSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="4-anl.html#SP17" class="function-link"><span class="function-syntax">ActionNameLists::has_clause</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="constant-syntax">NOUN_AP_CLAUSE</span><span class="plain-syntax">)) </span><span class="identifier-syntax">tc</span><span class="plain-syntax"> = </span><span class="constant-syntax">NOUN_AP_CLAUSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">TW</span><span class="plain-syntax"> = </span><a href="4-anl.html#SP17" class="function-link"><span class="function-syntax">ActionNameLists::get_clause_wording</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="identifier-syntax">tc</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="4-anl.html#SP37" class="function-link"><span class="function-syntax">ActionNameLists::explode_clause</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="identifier-syntax">tc</span><span class="plain-syntax">, </span><span class="identifier-syntax">Wordings::first_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">TW</span><span class="plain-syntax">));</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP37" class="paragraph-anchor"></a><b>&#167;37. </b>The following is recursive and exhausts all possible readings of the trailing
clause, exactly once each. We have to store what ought to be variables on the
stack as globals because of the little dance via Preform nonterminals below,
but the idea is simple enough. This function finds the first point at which
the reading diverges: for example, if the text is "banjo in the Conservatoire",
then "in" is the point of divergence. Maybe the text is all one clause, or
maybe it's just "banjo" and there is then a second clause "in the Conservatoire".
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">currently_exploding_entry</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">currently_exploding_clause</span><span class="plain-syntax"> = -1;</span>
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">explosions_count</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">ActionNameLists::explode_clause</span><button class="popup" onclick="togglePopup('usagePopup46')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup46">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::explode_clause</span></span>:<br/><a href="4-anl.html#SP36">&#167;36</a>, <a href="4-anl.html#SP41">&#167;41</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">tc</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">from_wn</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">saved</span><span class="plain-syntax"> = </span><span class="identifier-syntax">currently_exploding_entry</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">saved_C</span><span class="plain-syntax"> = </span><span class="identifier-syntax">currently_exploding_clause</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">currently_exploding_entry</span><span class="plain-syntax"> = </span><span class="identifier-syntax">entry</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">currently_exploding_clause</span><span class="plain-syntax"> = </span><span class="identifier-syntax">tc</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">TW</span><span class="plain-syntax"> = </span><a href="4-anl.html#SP17" class="function-link"><span class="function-syntax">ActionNameLists::get_clause_wording</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="identifier-syntax">tc</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">explosions_count</span><span class="plain-syntax">++;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">start</span><span class="plain-syntax"> = </span><span class="identifier-syntax">explosions_count</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOG_INDENT</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">w</span><span class="plain-syntax"> = </span><span class="identifier-syntax">from_wn</span><span class="plain-syntax">; ((</span><span class="identifier-syntax">w</span><span class="plain-syntax"> &lt; </span><span class="identifier-syntax">Wordings::last_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">TW</span><span class="plain-syntax">)) &amp;&amp; (</span><span class="identifier-syntax">start</span><span class="plain-syntax"> == </span><span class="identifier-syntax">explosions_count</span><span class="plain-syntax">)); </span><span class="identifier-syntax">w</span><span class="plain-syntax">++) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="function-syntax">&lt;text-precluding-divergence&gt;</span><span class="plain-syntax">(</span><span class="identifier-syntax">Wordings::one_word</span><span class="plain-syntax">(</span><span class="identifier-syntax">w</span><span class="plain-syntax">))) { </span><span class="identifier-syntax">w</span><span class="plain-syntax">++; </span><span class="reserved-syntax">continue</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">        </span><span class="function-syntax">&lt;detonate-at-divergence-points&gt;</span><span class="plain-syntax">(</span><span class="identifier-syntax">Wordings::from</span><span class="plain-syntax">(</span><span class="identifier-syntax">TW</span><span class="plain-syntax">, </span><span class="identifier-syntax">w</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOG_OUTDENT</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">currently_exploding_entry</span><span class="plain-syntax"> = </span><span class="identifier-syntax">saved</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">currently_exploding_clause</span><span class="plain-syntax"> = </span><span class="identifier-syntax">saved_C</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP38" class="paragraph-anchor"></a><b>&#167;38. </b>Note that if we spot the &lt;text-precluding-divergence&gt; wording immediately before
the point of divergence, we forbid divergence to occur. It must contain only
single words.
</p>

<p class="commentary">This actually matters surprisingly rarely, but enables us to handle quite
difficult cases like "Instead of buying the cheapest spice which is in the market"
without typechecking errors occurring on the unwanted case of reading this as
"Instead of buying the cheapest spice which is" plus the clause "in the market" &mdash;
the latter being, in fact, valid.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="function-syntax">&lt;text-precluding-divergence&gt;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">is</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">not</span>
</pre>
<p class="commentary firstcommentary"><a id="SP39" class="paragraph-anchor"></a><b>&#167;39. </b>Divergence points, then, must not unexpectedly use upper case &mdash; so "taking
Puss In Boots" is never read as possibly having an "in: Boots" clause; and
they either use the two standard wordings "in the presence of" or "in". or
else wording provided by a matching variable in an action declaration.
</p>

<p class="commentary">Note that this nonterminal never matches! It is parsed for its side-effect
of calling <a href="4-anl.html#SP41" class="internal">ActionNameLists::detonate</a> on every possibility.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="function-syntax">&lt;detonate-at-divergence-points&gt;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">_in</span><span class="plain-syntax"> </span><span class="identifier-syntax">_the</span><span class="plain-syntax"> </span><span class="identifier-syntax">_presence</span><span class="plain-syntax"> </span><span class="identifier-syntax">_of</span><span class="plain-syntax"> ... |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">_in</span><span class="plain-syntax"> ... |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;clause-opening&gt;</span><span class="plain-syntax"> ...</span>
</pre>
<p class="commentary firstcommentary"><a id="SP39_1" class="paragraph-anchor"></a><b>&#167;39.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Explode in</span><span class="named-paragraph-number">39.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">T</span><span class="plain-syntax"> = </span><span class="identifier-syntax">GET_RW</span><span class="plain-syntax">(</span><span class="function-syntax">&lt;detonate-at-divergence-points&gt;</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="4-anl.html#SP41" class="function-link"><span class="function-syntax">ActionNameLists::detonate</span></a><span class="plain-syntax">(</span><span class="constant-syntax">IN_AP_CLAUSE</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">T</span><span class="plain-syntax">, </span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="4-anl.html#SP39">&#167;39</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP39_2" class="paragraph-anchor"></a><b>&#167;39.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Explode in-presence</span><span class="named-paragraph-number">39.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">T</span><span class="plain-syntax"> = </span><span class="identifier-syntax">GET_RW</span><span class="plain-syntax">(</span><span class="function-syntax">&lt;detonate-at-divergence-points&gt;</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="4-anl.html#SP41" class="function-link"><span class="function-syntax">ActionNameLists::detonate</span></a><span class="plain-syntax">(</span><span class="constant-syntax">IN_THE_PRESENCE_OF_AP_CLAUSE</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">T</span><span class="plain-syntax">, </span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="4-anl.html#SP39">&#167;39</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP40" class="paragraph-anchor"></a><b>&#167;40. </b>For example, in the text "going from the Park to the Town", "from" and "to"
are divergence points:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="function-syntax">&lt;clause-opening&gt;</span><span class="plain-syntax"> </span><span class="identifier-syntax">internal</span><span class="plain-syntax"> ?</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Word::unexpectedly_upper_case</span><span class="plain-syntax">(</span><span class="identifier-syntax">Wordings::first_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">)) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">action_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">chief_an</span><span class="plain-syntax"> = </span><span class="identifier-syntax">currently_exploding_entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">item</span><span class="plain-syntax">.</span><span class="element-syntax">action_listed</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">chief_an</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">shared_variable_set</span><span class="plain-syntax"> *</span><span class="identifier-syntax">stvo</span><span class="plain-syntax"> = </span><span class="identifier-syntax">chief_an</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">action_variables</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">stvo</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">shared_variable</span><span class="plain-syntax"> *</span><span class="identifier-syntax">stv</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">LOOP_OVER_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">stv</span><span class="plain-syntax">, </span><span class="identifier-syntax">shared_variable</span><span class="plain-syntax">, </span><span class="identifier-syntax">stvo</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">variables</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">VW</span><span class="plain-syntax"> = </span><span class="identifier-syntax">stv</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">match_wording_text</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Wordings::starts_with</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">, </span><span class="identifier-syntax">VW</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">T</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Wordings::from</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">, </span><span class="identifier-syntax">Wordings::first_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">) + </span><span class="identifier-syntax">Wordings::length</span><span class="plain-syntax">(</span><span class="identifier-syntax">VW</span><span class="plain-syntax">));</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">potential_C</span><span class="plain-syntax"> = </span><a href="4-apc.html#SP2" class="function-link"><span class="function-syntax">APClauses::clause_ID_for_action_variable</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">stv</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                        </span><a href="4-anl.html#SP41" class="function-link"><span class="function-syntax">ActionNameLists::detonate</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">potential_C</span><span class="plain-syntax">, </span><span class="identifier-syntax">stv</span><span class="plain-syntax">, </span><span class="identifier-syntax">T</span><span class="plain-syntax">, </span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    }</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    ==&gt; { </span><span class="identifier-syntax">fail</span><span class="plain-syntax"> </span><span class="identifier-syntax">nonterminal</span><span class="plain-syntax"> };</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP41" class="paragraph-anchor"></a><b>&#167;41. </b>Finally the actual business of splitting our original entry into two, one
(called <span class="extract"><span class="extract-syntax">X</span></span> here) in which a new clause appears at the point of divergence,
and one (called <span class="extract"><span class="extract-syntax">Y</span></span>) where it does not.
</p>

<p class="commentary">The order is important here because this is why when there are multiple
readings of clauses in the ramified list, the readings with more clauses
come before the readings with fewer.
</p>

<p class="commentary">Note that we only diverge if the new clause is one which does not already
exist for this entry. This is because it makes no sense to have the same
clause twice, and also means that pathological text like "in in in in in
in in in in in in in in in in in in in in in in in in in in in in in in in"
cannot cause a combinatorial nightmare; because each clause appears at
most once in any entry, the number of entries produced by ramification is
capped at \(2^n\), where \(n\) is the number of different clauses whose matching
words appear somewhere in the text. As Inform ships with only seven different
clauses anyway, this will never be too bad.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">ActionNameLists::detonate</span><button class="popup" onclick="togglePopup('usagePopup47')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup47">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::detonate</span></span>:<br/><a href="4-anl.html#SP39_1">&#167;39.1</a>, <a href="4-anl.html#SP39_2">&#167;39.2</a>, <a href="4-anl.html#SP40">&#167;40</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">potential_C</span><span class="plain-syntax">, </span><span class="identifier-syntax">shared_variable</span><span class="plain-syntax"> *</span><span class="identifier-syntax">stv</span><span class="plain-syntax">, </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">T</span><span class="plain-syntax">, </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">W</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="4-anl.html#SP17" class="function-link"><span class="function-syntax">ActionNameLists::has_clause</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">currently_exploding_entry</span><span class="plain-syntax">, </span><span class="identifier-syntax">potential_C</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">extra</span><span class="plain-syntax"> = </span><a href="4-anl.html#SP26" class="function-link"><span class="function-syntax">ActionNameLists::duplicate_entry</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">currently_exploding_entry</span><span class="plain-syntax">);</span>

<span class="plain-syntax">        </span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">Y</span><span class="plain-syntax"> = </span><span class="identifier-syntax">extra</span><span class="plain-syntax">, *</span><span class="identifier-syntax">X</span><span class="plain-syntax"> = </span><span class="identifier-syntax">currently_exploding_entry</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><a href="4-anl.html#SP18" class="function-link"><span class="function-syntax">ActionNameLists::set_clause_wording</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">potential_C</span><span class="plain-syntax">, </span><span class="identifier-syntax">T</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">anl_clause</span><span class="plain-syntax"> *</span><span class="identifier-syntax">extra_clause</span><span class="plain-syntax"> = </span><a href="4-anl.html#SP17" class="function-link"><span class="function-syntax">ActionNameLists::get_clause</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">potential_C</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">extra_clause</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">stv_to_match</span><span class="plain-syntax"> = </span><span class="identifier-syntax">stv</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><a href="4-anl.html#SP20" class="function-link"><span class="function-syntax">ActionNameLists::truncate_clause</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">currently_exploding_clause</span><span class="plain-syntax">, </span><span class="identifier-syntax">Wordings::first_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">));</span>

<span class="plain-syntax">        </span><span class="reserved-syntax">anl_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">n</span><span class="plain-syntax"> = </span><span class="identifier-syntax">currently_exploding_entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next_entry</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">currently_exploding_entry</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next_entry</span><span class="plain-syntax"> = </span><span class="identifier-syntax">extra</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">extra</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next_entry</span><span class="plain-syntax"> = </span><span class="identifier-syntax">n</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><a href="4-anl.html#SP37" class="function-link"><span class="function-syntax">ActionNameLists::explode_clause</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="identifier-syntax">currently_exploding_clause</span><span class="plain-syntax">, </span><span class="identifier-syntax">Wordings::first_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">)+1);</span>
<span class="plain-syntax">        </span><a href="4-anl.html#SP37" class="function-link"><span class="function-syntax">ActionNameLists::explode_clause</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">potential_C</span><span class="plain-syntax">, </span><span class="identifier-syntax">Wordings::first_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">T</span><span class="plain-syntax">)+1);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP42" class="paragraph-anchor"></a><b>&#167;42. </b>Lastly, this little function is provided for unit testing the above, and
is otherwise never called.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">ActionNameLists::test_list</span><button class="popup" onclick="togglePopup('usagePopup48')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup48">Usage of <span class="code-font"><span class="function-syntax">ActionNameLists::test_list</span></span>:<br/>Parse Clauses - <a href="4-pc.html#SP4">&#167;4</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">W</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"Action name list for: %W\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">action_name_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">anl</span><span class="plain-syntax"> = </span><a href="4-anl.html#SP29" class="function-link"><span class="function-syntax">ActionNameLists::parse</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">, </span><span class="identifier-syntax">IS_TENSE</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"$L\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">anl</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<nav role="progress"><div class="progresscontainer">
    <ul class="progressbar"><li class="progressprev"><a href="4-ap2.html">&#10094;</a></li><li class="progresschapter"><a href="P-wtmd.html">P</a></li><li class="progresschapter"><a href="1-im.html">1</a></li><li class="progresschapter"><a href="2-bd.html">2</a></li><li class="progresschapter"><a href="3-sm.html">3</a></li><li class="progresscurrentchapter">4</li><li class="progresssection"><a href="4-ap.html">ap</a></li><li class="progresssection"><a href="4-anaa.html">anaa</a></li><li class="progresssection"><a href="4-ak.html">ak</a></li><li class="progresssection"><a href="4-ac.html">ac</a></li><li class="progresssection"><a href="4-act.html">act</a></li><li class="progresssection"><a href="4-as.html">as</a></li><li class="progresssection"><a href="4-av.html">av</a></li><li class="progresssection"><a href="4-ann.html">ann</a></li><li class="progresssection"><a href="4-ap2.html">ap2</a></li><li class="progresscurrent">anl</li><li class="progresssection"><a href="4-apc.html">apc</a></li><li class="progresssection"><a href="4-pap.html">pap</a></li><li class="progresssection"><a href="4-pc.html">pc</a></li><li class="progresssection"><a href="4-ea.html">ea</a></li><li class="progresssection"><a href="4-nap.html">nap</a></li><li class="progresssection"><a href="4-gng.html">gng</a></li><li class="progresssection"><a href="4-rpoa.html">rpoa</a></li><li class="progresschapter"><a href="5-pp.html">5</a></li><li class="progresschapter"><a href="6-dlg.html">6</a></li><li class="progressnext"><a href="4-apc.html">&#10095;</a></li></ul></div>
</nav><!-- End of weave -->

		</main>
	</body>
</html>

